Forum Discussion

aemery's avatar
aemery
New Contributor
4 years ago

REST PUT - Where to put Body Message

Hello,

I have a REST service that first requires a PUT with a JSON body with the username/password in the body, and it will return a key. I can get it to work in SoapUI and Postname, but am unable to figure out how to make it work in Snaplogic.

I constructed what was used as the Body in Postman in the JSON Generator snap -

[
{
“username”: “someuser”,
“password”: “somepassword”
}
]

However how do I call that from the REST Put snap?

Thanks in advance for any assistance.

5 Replies

  • aemery's avatar
    aemery
    New Contributor

    Ok, so I put this JSON (user/pass redacted) in the HTTP Entity field -
    {“username”: “USER”, “password”:“PASS”}

    This is the same JSON string that works when I use Postman or SoapUI.

    And I got this error -
    Provided JSON is incorrect

    Resolution:

    Please ensure that the provided JSON is correct

    Reason:

    Unexpected character (‘C’ (code 67)): Expected space separating root-level values at [Source: (String)“1CE2D9161EF94E548076FAD3BCA6A4F7”; line: 1, column: 3]

  • You need to enable the expression field if you want to use json inside the http entity setting. ( Just click on the = sign ). If you don’t enable the expression, then everything inside this property will evaluate to a string, which is why the error is telling you that you provided incorrect JSON.

    • aemery's avatar
      aemery
      New Contributor

      ok, that got me further, however the service returns a text/plain object so now Snaplogic gives an error saying it is expecting JSON. I set the following so that it would accept any object -

      Accept = */*

      Edit: the asteriks were removed from the post

      • aemery's avatar
        aemery
        New Contributor

        Ok I figured it out -

        I changed this setting from default to text -