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,359

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
maik_bosch
Contributor
0 Kudos

Hi Shikha,

please see that error code 400 means bad request. So it seems like message is not well formed. I also use postman first to make it working there and then later try to make it work in CPI. If I getting for same requests errors in CPI usually it is based on the Adapter in CPI. But with HTTP Adapter it should work with exactly the same payload like in Postman

BR

Maik

former_member323756
Participant
0 Kudos

Hey Maik,

Thank you for responding.

Please correct me if you find my statement wrong. But would HTTP 400 also not mean that 'the end application didnt understood my request'.- not necessary that it isn't well formed but the communication language probably is there.

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.

Regards,

Shikha

maik_bosch
Contributor

Hi Shikha,

just have a look at the headers area in Postman.

Depending on what you select in the Body area the content of the Header: "Content-Type" will change

See for GraphQl headers also:

https://graphql.org/learn/serving-over-http/

So maybe something is missing/ different there? The headers used in CPI you will also find in the traces mentioned by Saurabh

BR

Maik

former_member323756
Participant
0 Kudos

Hello Maik,

In this case since the header Content-Type via postman was 'application/json', I was using the same in CPI. But seems since we are passing GraphQL and not json in Body , probably as per your shared blog , I should try 'application/graphql' . I didn't even know if that was a valid header. Thanks for this blog . Let me try the same and I will update the post with the result.

Regards,

Shikha

former_member323756
Participant
0 Kudos

Hello Maik,

I tried posting the GraphQL request payload from CPI again by declaring the Content type header as 'application/graphql'.

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