Solved

HTTP POST error

  • 9 April 2024
  • 4 replies
  • 90 views

Userlevel 2
Badge +1

Hello,

 

I have a post request configured like this in SF:

Post configured in SF

The json process variable has the domain NVARCHAR_MAX and I have set it as expression like this :

I am getting this error :  "output_msg": "{\"type\":\"https://tools.ietf.org/html/rfc7231#section-6.5.1\",\"title\":\"One or more validation errors occurred.\",\"status\":400,\"traceId\":\"00-648ea2cae71b699ed4c7d5b1a2a39c03-bbb250a5817874a4-00\",\"errors\":{\"json\":[\"The json field is required.\"]}}".

The indicium gets : 400 bad request.

 

What I am missing or doing wrong?

icon

Best answer by Vincent Doppenberg 9 April 2024, 16:41

View original

4 replies

Userlevel 6
Badge +4

Hello @Sulea Ema,

It looks like the API that you are calling is expecting a property called “json” in the request body. I don't know which API you are calling, so it's hard for me to be more specific, but perhaps it's expecting the body to be like this?

{
"json": [
{
"first_name": "...",
...
}
]
}

I hope this helps.

Userlevel 2
Badge +1

Hello @Vincent Doppenberg .

The method I am calling is expecting a string variable called json.This is how it looks when I try the call in postman with a key (variable called in the same way the variable from the method is called).

If I try in postman with a body and the example you @Vincent Doppenberg presented me above I get this :

(I have also tried both cases in SF too .I am getting the same error 400.)

Is the contet-type application/json from sf the right way to go in this case .What content-type should I try to use? Or do you have any other lead ?

 

Thank you @Vincent Doppenberg !

Userlevel 6
Badge +4

Hello @Sulea Ema,

What you are doing in Postman here:


Is simply a querystring parameter, which is part of the request URL, not of the request body. To achieve that, you can simply add ?json={json} here:

 

To be clear, the {json} part is a reference to your process variable called ‘json’. Its value will be inserted into the URL at that location. So it's really ?json={process_variable_id} and you enter the ID of the process variable that you want to be inserted at that location.

As for the Content-Type and Content input parameters, I can't tell from your picture what you are sending in Postman:


But perhaps you can simply leave both of them empty, as it looks like you're posting the data through the querystring parameter in the URL.

I hope this helps.

Userlevel 2
Badge +1

Hi @Vincent Doppenberg ! 

 

We have made it work .We have changed the parameter methode we were calling to be a body. It worked calling it from SF. Your answer helped us looking into detail about what exactly we need to send as paramater from SF and also in the method build.

Thanks @Vincent Doppenberg !

Reply