Microgateway Rest API POST JSON message body missing - DFHWrapper error

I'm using Apigee Microgateway (2.5.12) to call a backend unsecured CICS application. I'm making a POST request with a valid JSON and using only oauth plugin. I'm passing below headers with my request:

x-api-key <key> 
Content-Type application/json 
Accept application/json 

I'm receiving below error:

{
    "Fault": {
        "faultstring": "Failure interacting with CICS",
        "detail": {
            "CICSFault": "Failure to parse JSON request for WEBSERVICE <svcName> and HTTP Method POST: Error obtaining parser from data source:Missing value. at character 13 of {DFHWrapper: }"
        }
    }
} 

It looks like the JSON message body is not being forwarded by Apigee to CICS. I've tried from Postman and SoapUI, have validated that the JSON is valid, have confirmed that all headers are set correctly, have verified that the CICS API works when invoked directly (without through Apigee).

Any idea what might be causing this error? Are any additional settings required in Edge or MGW to allow JSON to pass? Is there a way to capture the outgoing message from MGW or Edge?

0 4 489
4 REPLIES 4

Former Community Member
Not applicable

Microgateway enables streaming be default. Could that be a reason?

@srinandans - could you kindly elaborate a little about how streaming might affect? My JSON request is not large, the entire request is 292 bytes. I tried sending the same post to a publicly available JSON API [http://jsonplaceholder.typicode.com/posts/1] and that works. So I'm wondering if there are any know restrictions on CICS to read JSON sent from Apigee or are additional headers required.

Former Community Member
Not applicable

Hmm. That is strange. If there is a way to send the MG requests through a MITM proxy you can see what is actually being sent (in terms of headers). Compare that with what Postman does.

@srinandans - to update on this - we found out that the problem was because the "Content-Length" header was missing in the http post calls that were reaching CICS. Once we add that POST calls work successfully. Do you know why microgateway is removing Content-Length header?
https://github.com/apigee/microgateway-core/blob/master/lib/plugins-middleware.js lines 166-169