WEB CONVERSE to an api returns invalid request error (RC=400)

116 Views Asked by At

I am trying to make rest api call from my cics-cobol program. The Web-Open was successful. During the web converse i am getting return code = 400 with response - {"detail":"There was an error parsing the body"}.

When do we usually get such errors? The API call to the same URL with same JSON request body works fine from POSTMAN. But through web converse i am not able to get the same response. Any suggestions on how to fix this?

In order to compare the body received by both means (by cics & by postman), is there a way to put print statements in the api call to see the body it has received?

2

There are 2 best solutions below

1
cschneid On

When do we usually get such errors?

When you say "return code" I am going to presume you mean "http status code" because 400 is neither a valid value for EIBRESP nor EIBRESP2 in this context.

An http status code of 400 means...

The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

...so presuming (because you don't say explicitly and you haven't provided your code) you are using a POST to send content, then the content isn't what the API expects.

The API call to the same URL with same JSON request body works fine. But through web converse i am not able to get the same response. Any suggestions on how to fix this?

Whatever means you are using (because you don't say what that is) to make this "API call to the same URL with the same JSON request body" is doing something different than what you're doing in your code (which you don't provide).

Checking EIBRESP and EIBRESP2 might help. Comparing what is being sent, including http headers, between your code and the code that works might help.

0
Mahalakshmi K On

I was able to make it work. It was an issue with the length that was supplied to the WS-FROM field. Future note: Validate every single field!

Thanks for taking time to read my query.