Can I add raw data to the Post URL Request?
for example:
HTTP://token.abc/v1/oatuh2/rest/token{"OrgID: ABC", "sport:basketball"}
image below is from postman for understanding
Related
I have database in backendless, where I am trying to make POST request. If I open rest console in backendless admin page, there is no problem with making correct POST request. However when I want to make POST from postman it doesn't work, I get error
"code": 8002,
"message": "Could not parse request with message: Error decoding json body: null, status code 400, headers POST
Here is screenshot from backendless as well as from postman. I don't understand, why it is working only from backendless console. Could someone help me, where is the problem? Thanks
You should make POST request with JSON body.
To do it, add
Content-Type: application/json header and define the json body in raw Body tab
I found it confusing too, before I watched a video and realized that I needed to type into the text editor under the Body tab directly under the POST request URL, and not in the output section.
screenshot from postman
I am creating Rest API but I am confused in URL structure. I have to send just one parameter to server in my Post request. should I send it through path variable or in request body? what are the best practices?
Example Current URL:
api/v1/users/{id}/name/{name}
name is the variable I want to send to server for to change state
Thanks
URL usually identifies resource you want to update.
So the data should go inside in request body
To update user name you may send this to server:
POST api/v1/users/{id} HTTP/1.1
Content-Type: application/x-www-form-urlencoded
name=string
I would have a question concerning the properties which will be transfered from client to server.
HTTP GET is clear: Parameters are transmitted in URL and not in body!
HTTP PUT: where to transmit parameters - in URL or Body?
HTTP POST: where to transmit parameters - in URL or Body?
HTTP DELETE: where to transmit parameters - in URL or Body?
Thanks a ot for answering the question!
The id of the entity in PUT (update) and DELETE request should be in the url. The entity to update in PUT requests should be in the body. The entity to create in POST requests should also be in the body.
Optional parameters should be sent in query string. Other contextual information on the entity (Composite id) should be in the url.
I am designing a RESTful API when I noticed something strange.
When I make a POST request for creating a new record, the form data is sent in request payload.
But when I make a PUT request to update a record, it appends form data in the URL, very similar to GET request.
Now a URL has certain length limit. So what would happen if PUT request has larger data than this limit.
Will the PUT request fail?
Is it unsafe to use PUT instead of POST to update a record having large form data?
EDIT:
I am using NodeJS server. I am using restangular(angular framework) to build my PUT request.
Use customPUT to send the form data in payload.
baseObj.customPUT(newObj).then(function(xyz){})
Have a look at these threads
Can HTTP PUT request have application/x-www-form-urlencoded as the Content-Type?
PHP multipart form data PUT request?
application/x-www-form-urlencoded or multipart/form-data?
Sounds like you can basically set a Content-type: multipart/form-data header and be golden. Basically comes down to configuration of the request with restangular and support thereof on the NodeJS server.
I use the ASIHttpRequest in my ios project, and my workmate use the Tastypie as the server, he told me I must post a String with JSON format as Http body(use application/json), but I can't find this Content-Type besides "application/x-www-form-urlencoded" and "multipart/form-data".
then How can I send a POST request with JSON format in ASIHttpRequest?