VS Code:
Version: 1.28.2 (system setup)
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:23:51.859Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
OS:
Windows 7 Enterprise SP 1
RESTClient version 0.20.2
I have this request in RESTClient:
POST https://example.com/backend/saveData.php
content-type: application/json
{
"id": "123",
"firstname": "test",
"lastname" : "testing",
}
In saveData.php I have:
<?php
$idNum = filter_input( INPUT_POST, 'id' );
$firstName = filter_input( INPUT_POST, 'firstname' );
$lastName = filter_input( INPUT_POST, 'lastname' );
$rv= '{"id":"'.$idNum.'","fn":"'.$firstName.'","ln":"'.$lastName.'"}';
echo($rv);
exit();
When I send the request via RESTClient, none of the POSTed parms are making it to the PHP code.
Getting back this response:
HTTP/1.1 200 OK
Date: Fri, 19 Oct 2018 17:29:42 GMT
Server: Apache/2.4.9 (Win64) PHP/5.5.12
X-Powered-By: PHP/5.5.12
Content-Length: 25
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
{
"id": "",
"fn": "",
"ln": ""
}
Not sure if this is a known issue already.
@lcarbonaro I am not familiar with PHP, however in my test, the request sent out by my extension is right IMHO, and you can verify this by sending following request in my extension:
POST http://httpbin.org/post
content-type: application/json
{
"id": "123",
"firstname": "test",
"lastname" : "testing",
}
@lcarbonaro are you looking into post parameters are url form data instead of json content? The request below should work with your PHP.
`POST https://example.com/backend/saveData.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
id=123&firstname=test&lastname=testing`
Thanks @Huachao and @rafaltra for your responses. @rafaltra your suggestion worked - thank you.
@lcarbonaro are you looking into post parameters are url form data instead of json content? The request below should work with your PHP.
`POST https://example.com/backend/saveData.php HTTP/1.1
Content-Type: application/x-www-form-urlencodedid=123&firstname=test&lastname=testing`
Solved my problem, thank you.
Most helpful comment
@lcarbonaro are you looking into post parameters are url form data instead of json content? The request below should work with your PHP.
`POST https://example.com/backend/saveData.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
id=123&firstname=test&lastname=testing`