Jerry
Jerry

Reputation: 111

wso2 Could not save JSON payload. Invalid input stream found

  1. This is my very first REST API in WSO2, the sequence in wso2 as below.

<? xml version = "1.0" encoding = "UTF-8" ?>
< api xmlns = "http://ws.apache.org/ns/synapse"
    name = "createIssue"
    context = "/rest"
    hostname = "XXX"
    port = "XXX" >
      < resource methods = "POST"
    inSequence = "createInSequence"
    `enter code here`
    outSequence = "createOutSequence" >
      < faultSequence / >
      < /resource>
</api >



      <? xml version = "1.0"
    encoding = "UTF-8" ?>
      < sequence xmlns = "http://ws.apache.org/ns/synapse"
    name = "createInSequence" >
          < log level = "custom" >
          < property name = "location"
          expression = "json-eval($.fields)" / >
      < /log>
      </sequence >

  1. The curl command that I am making to invoke the api, is as below.

    'curl -X POST -H "Content-Type:application/json" -d@"h:\createissue_own.json" "http://ip:port/rest/api/createissue"'

  2. WSo2 esb Console shows the following error

    newJsonPayload. Could not save JSON payload. Invalid input stream found.'

  3. The input json, is a valid json, which I have validated and given below.

{
  "fields": {
    "project": {
      "id": "10301"
    },
    "summary": "Issue",
    "description": "Description text",
    "issuetype": {
      "id": "10205"
    },
    "customfield_10600": {
      "id": "10300"
    },
    "customfield_10602": {
      "id": "10301"
    },
    "customfield_10603": "ID text",
    "customfield_10608": {
      "id": "10303"
    },
    "customfield_10609": " text",
    "customfield_10610": " text",
    "customfield_10611": " text",
    "customfield_10612": "Postcode text"
  }
}

Any suggestions please. I am not able to hit the url, and log the input json.

Upvotes: 2

Views: 4306

Answers (1)

Ravindra Ranwala
Ravindra Ranwala

Reputation: 21124

This error usually comes when you send XML payload with application/json Content-Type header to the ESB. The best thing we can do here is enable the wirelogs and check the HTTP headers and payloads sent to the ESB. To enable wirelogs follow these steps,

  • Shutdown the ESB instance
  • Move onto the $ESB_HOME/repository/conf directory and locate the log4j.properties file Then uncomment the following line

    log4j.logger.org.apache.synapse.transport.http.wire=DEBUG

  • Then restart the ESB instance again and send a request

Monitor the ESB console for wirelogs as follows

The symbol '>>' gives the contents written into the ESB and '<<' gives the contents written out of the ESB.

Also I doubt your curl command, hence a sample curl command is given below.

   curl -v -d @test.json -H "Content-Type:application/json" http://localhost:8280/rest/api/createissue

Upvotes: 1

Related Questions