Forum Discussion

debby12's avatar
debby12
New Contributor
13 years ago

JSON Body in REST Post method

Hi,
I'm trying to create a REST Request for a POST Method, using JSON data in the body.
Few Questions:
Should I configure the JSON parameters in Method Parameters? Or should I place the whole JSON text in the body?
Currently I'm placing the whole JSON Content in the body, and checking in the PostQueryString Checkbox.
Please see the following JSON used:
{
"FieldType":string,
"Operator":EQ,
"Field":status,
"Value":effective
}
Any idea what can be wrong in what I'm doing?
Currently I'm getting error code 401, (there is no problem with session id in the header, I'm using the same session id transfer in Get Calls and it works successfully.

Any idea and additional information can be very helpful.
Thanks!

4 Replies

  • I came here looking for the exact same answer.

    I have a WCF-based REST service that takes in either overly complicated xml or simple JSON data as the body. I can get it to work just fine by putting the formatted text manually into the body and setting media type "application/json" and it works fine. But I'd really like to get the parameters working so that I can do more with a request in the testing side of things.
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Works for me with HTTP request. Set method to POST, set Media Type to 'application/json', put JSON string in the body and do not check 'Post QueryString'.
  • NathanielS's avatar
    NathanielS
    New Contributor
    Got this working now

    In the post > request
    Something like this ...

    {
    "Destination":${#Project#Destination},
    "DeviceId":${#Project#DeviceId},
    "LocationId":${#Project#locId},
    "UserId":${#Project#userId
    }