cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI issue HTTP operation failed invoking https://xyz/graphql with statusCode: 400

former_member323756
Participant
0 Kudos
5,389

Hello All,

Our requirement is to query a GraphQL based api from CPI and push the response to C4C for ticket creation and customer creation.

So we are able to fetch the Bearer token for OAuth based authentication in CPI but when I try to push the same graphql request payload from CPI to the Rest API endpoint which is very much working and giving the response back from Postman, it gives the underlying error

"Error Details

org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://xyz/graphql with statusCode: 400 "This API request in GraphQL would give a JSON response and the same can be handled by CPI using standard convertors available.

But the API not being able to comprehend my GraphQL request itself is the issue.

Update to clarify:

When I say that exactly the same payload worked with postman successfully but did not work with CPI HTTP adapter. The only difference there is as per my observation has been the radio button that we select to announce the request content type in POSTMAN.

I havnt found a way to tell my CPI editor that this is a GraphQL request payload that i am posting.

Not sure what header/parameter do I need to update to replicate this setting in CPI.

Note: I have maintained each and every header as postman in CPI too. But none states anything about GraphQL content type.

How should I handle the scenario here. Any suggestions ?

Regards,

Shikha

palash_mazumder
Participant
0 Kudos
It working with Content-Type = application/graphql
View Entire Topic
former_member226
Employee
Employee
0 Kudos

Hello,

Adding to what Maik has already said, you can also enable trace(or BLOG) to see the actual payload/mesage content being passed from the HTTP adapter to external graphql API. This will give you a fair idea if there is any parameter missing or some extra line breaks are generated by CPI (in case of batch mode) etc etc.

BR

former_member323756
Participant
0 Kudos

Hello Saurabh,

Thanks for your response. I already checked traces and the payload isn't changing any further then what I pass<HARDCODED> from Content modifier in the Body section.

Regards,

Shikha

former_member226
Employee
Employee
0 Kudos

but then as you mentioned in last answer to Maik, did you pass the content-type as header from the content modifier step so that the request could be understood by the target server(in this case graphql server endpoint)

You can check the "Content-Type" value from postman code section as shown:

former_member323756
Participant
0 Kudos

Yes Saurabh.

I did pass the content-type as header from content modifier as 'application/json' since the same is working via postman.

Now I will be trying to pass the same as 'application/graphql' instead as is indicated in blog shared by Maik.

Regards,

Shikha

former_member323756
Participant
0 Kudos

Hello Saurabh,

Tried posting the GraphQL request payload from CPI again by declaring the Content type header as 'application/graphql' although in Postman it is 'application/json' for this request.

The error now changed to :

"org.apache.camel.component.ahc.AhcOperationFailedException: HTTP operation failed invoking https://api.iadvize.com/graphql with statusCode: 415"

which means this is an Unsupported Media Type.

Any other suggestions please.

Regards,

Shikha

former_member226
Employee
Employee
0 Kudos

Hmmm... But http-415 means that when you passed "application/graphql" as the content-type header then the target graphql server didn't even accept the request with the content type mentioned. Hence my assumption would be that grapql server is expecting content-type other than "application/graphql", but thats the max we can guess just by looking at the explanation or pictures you have shared.

Have you tried contacting SAP support? What they say?

former_member323756
Participant
0 Kudos

Hello,

You are very correct.

Before even attempting this , I was aware that the graphql server i.e iAdvize in our case expects

content-type header to have"application/json " as is clearly stated in there documentation. But having tried that already ,since the HTTP 400 was coming in that case.

I just am not sure what should be the header to explain this request as GraphQL to the server (like the Postman->radio button serves that purpose).

Hence tried this change of content type "application/graphql" as hinted by blog that Maik shared.

The ticket is open with SAP .Still waiting for responce

Regards,

Shikha

former_member664177
Discoverer
0 Kudos

Hello Shikha,

Were you able to find a solution to this issue.

I am getting same error and need support.

Thanks.