0

I am sending parameters with a GET in the JSON body of Postman but the data is not written into the DybnamoDb. If I send the parameters through the url they are written. Here is the format I use in Postman. I get a 200 OK status .

enter image description here

If I send the parameters through the url as

http://localhost:56943/api/dynamodb/putitems?id=3&replyDateTime=63668789020007000&price=10.25

the data is put in the database.

donotbea
  • 73
  • 9
  • `GET` request's body is ignored: https://stackoverflow.com/questions/978061/http-get-with-request-body – mickl May 08 '20 at 23:07
  • Then why did Postman add body to the GET messages in their latest update? – donotbea May 08 '20 at 23:21
  • I will change it to a post. – donotbea May 08 '20 at 23:23
  • from the link I pasted: "So, yes, you can send a body with GET, and no, it is never useful to do so.". The protocol itself allows you to do it but it will be ignored by most servers – mickl May 08 '20 at 23:23
  • Postman allows to send get with request body, that doesn't means that API will accept that, the behaviour of http requests are defined in RFC documents and they gets updated with enhancements, that doesnt mean everyAPIs are implemented with latest RFC. – Shivam Seth May 08 '20 at 23:28
  • Also, this isn't a new thing that's been recently added to the app, it's been in there for a long time. – Danny Dainton May 09 '20 at 08:35

1 Answers1

2

API is function binded to particular web uri, and every function defines it arguments type and place to accept input ( body or header param or path param.. etc)

So you just cannot pass parameters in request body as json, if the calling API is expected to take input as query params.

How to send parameters to any API (as body or as query params) are defined by API developer, If it is publicly exposed API, then there will be documentation defined API request and response.

Edited ( to add more information based on comment)

Behaviour of http methods are defined in RFC documents and these documents are updated time to time with new features or bug fixes.

The API can be written by developer using older version of HTTP server or client, that doesn't allow certain features.

Whereas postman as a tool wants to keep it ahead of race, so it has added new features so everyone who is using either old or new can use.

Community
  • 1
  • 1
Shivam Seth
  • 632
  • 1
  • 5
  • 18