Service Callout response not getting populated

Hi

I have API Gateway deployed on private Google cloud.

I am having API Proxy which has a policy of Service Callout where it fetches the response and do some processing.

Somehow when I execute the curl command of the service which is mentioned in Service Callout directly on Gateway box, I get the response but when it does through Service callout , it doesn't get any response.

Attaching the API Proxy bundle for reference and the curl command response

Any help would be highly appreciated.

document-rev1-2016-04-25-1.zip

curl-response.txt

Thanks

Gaurav

2 10 1,247
10 REPLIES 10

@GAURAV , Content-Type header is missing in the service callout request, is that the problem ?

Hi @Anil Sagar

I have tried that also but it didn't work

Added below lines in PrepareRequest policy of the bundle

<Headers> <Header name="Content-Type">application/json</Header> </Headers>

Also this API Proxy was working fine in version 4.15.0.7 Edge deployed on AWS but not working in 4.16.0.1 deployed on Google cloud.

Thanks

Gaurav

@GAURAV,

I had a look into your API bundle and also the curl response and have the following suggestions:

1. The ServiceCallout Policy has the flag continueOnError="true". Please set this to "false", else the policy will continue to run even though there are errors. Infact, it could be possible that the ServiceCallout policy had an error and hence it did not populate the response. You can read more about the Response element in this link

2. Have you tried running the curl command directly from the MPs ? If not, please try running from the MPs and see if you are getting successfull response or any errors.

3. I noticed that your curl request is POST, so add the below line as part of the request in your ServiceCallout policy. This is in addition to setting Content-Type as "application/json"

<Verb>POST</Verb>

4. You can have Javascript code to access the response variable from the ServiceCallout policy. Read more about this in the community post here

Regards,

Amar

Hi @AMAR DEVEGOWDA

1. Set the continueOnError flag to false and now I got the below error

{ "fault": { "faultstring": "Execution of ServiceCallout AuthenticateUser failed. Reason: Host not reachable", "detail": { "errorcode": "steps.servicecallout.ExecutionFailed" } } }

It says host not reachable but as earlier pointed out that I can execute the curl command of the same service successfully.

2. How can i try running the curl directly from MP ?

3. I already have the below line in PrepareRequest policy.

4. I already have the Cookie Setter where I am printing the response variables like response status code and response headers, they all are coming null.

Thanks

Gaurav

adas
New Member

@GAURAV The endpoint you are trying to hit may not be open from the the message processor's IP. Does that endpoint have some sort of whitelisting ? You can ssh to the message-processor machine and try doing a curl - "curl -v http://myurl.com/test" with your url and see what happens.

If you are hitting a specific port on the target server, try doing a telnet to that port.

Hi @arghya das @naveen

We have AIO set up so MP is on the same machine from where I am executing the curl command and it is giving the right response

Please see the attached response

mp-curl-response.txt

Not applicable

@GAURAV

1. Set the continueOnError flag to false and now I got the below error

{ "fault": { "faultstring": "Execution of ServiceCallout AuthenticateUser failed. Reason: Host not reachable", "detail": { "errorcode": "steps.servicecallout.ExecutionFailed" } } }

>> This could be issue with authenticating the MPs .Kindly check if necessary MP IPs whitelisted.If that is not the issue then kindly look into the MP logs (it could also be a SSL handshake issue )

It says host not reachable but as earlier pointed out that I can execute the curl command of the same service successfully.

2. How can i try running the curl directly from MP

>> Log into the MP box using ssh or telnet and run the curl command from the shell.Befoe running the curl command do a ping for the backend,to rule out any netwrok issues.Once you are able to ping the back end successfully then try to run the curl command and check the response.My hunch is it might be an SSL handshake issue .Use "-v" option in curl to get a verbose output

3. I already have the below line in PrepareRequest policy.

>> this is fine

4. I already have the Cookie Setter where I am printing the response variables like response status code and response headers, they all are coming null.

>> this is fine

adas
New Member

Can you attach your proxy zip file so that I can take a look.

@arghya das,

Gaurav informed me that the issue is not seen after they restarted the Message processor.

Not applicable

Hi ,

I have the same issue with Service Callout , it is throwing below error. I have attached my proxy bundle here.withoutapikey-rev1-2018-02-23.zip

{
"fault": {
"faultstring": "Execution of ServiceCallout SC-DvlaToken failed. Reason: ResponseCode 400 is treated as error",
"detail": {
"errorcode": "steps.servicecallout.ExecutionFailed"
}
}
}