简体   繁体   English

WSO2 API管理器POST正在剥离JSON

[英]WSO2 API manager POST is stripping the JSON out

I'm hitting my endpoint, but the API manager seems to be stripping out the JSON before it gets there, so it's always empty. 我碰到了端点,但API管理器似乎在到达JSON之前就剥离了JSON,因此它始终为空。 I set it up to be a post producing and consuming application/json. 我将其设置为后期制作和使用的application / json。 I really just want to be able to dump JSON into the request body and have it be passed on to my endpoint without conversion. 我真的只是希望能够将JSON转储到请求正文中,并将其传递到我的端点而无需进行转换。 My swagger file: 我的摇摇欲坠文件:

paths:
  /consumers:
    post:
      responses:
        '200':
          description: ''
      parameters:
        - name: Payload
          description: Request Body
          required: true
          in: body
          schema:
            type: object
            properties:
              mobile_phone_num:
                type: string
      produces:
        - application/json
      consumes:
        - application/json
      summary: Add a Spring consumer
      x-auth-type: Application & Application User
      x-throttling-tier: Unlimited

and the cUrl: 和cUrl:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer eb29216f-134e-3fde-aa0d-88a513fb0bc8' -d '{"mobile_phone_num":"string"}' 'https://192.168.0.3:8243/burrito/1.0.0/consumers'

and the wirelog: 和电汇:

[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "OPTIONS /burrito/1.0.0/consumers HTTP/1.1[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Host: 192.168.0.3:8243[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Access-Control-Request-Method: POST[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Origin: https://localhost:9443[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Access-Control-Request-Headers: authorization,content-type[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept: */*[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Referer: https://localhost:9443/store/apis/info?name=SpringConsumer&version=1.0.0&provider=admin&tenant=carbon.super[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept-Language: en-US,en;q=0.8[\r][\n]"
[2017-07-20 10:20:25,577] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "HTTP/1.1 200 OK[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Origin: https://localhost:9443[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Accept: */*[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Request-Method: POST[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Origin: *[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Methods: POST[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Request-Headers: authorization,content-type[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Referer: https://localhost:9443/store/apis/info?name=SpringConsumer&version=1.0.0&provider=admin&tenant=carbon.super[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Host: 192.168.0.3:8243[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Accept-Language: en-US,en;q=0.8[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Date: Thu, 20 Jul 2017 14:20:25 GMT[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Transfer-Encoding: chunked[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Connection: keep-alive[\r][\n]"
[2017-07-20 10:20:25,581] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "[\r][\n]"
[2017-07-20 10:20:25,582] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "0[\r][\n]"
[2017-07-20 10:20:25,582] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "POST /burrito/1.0.0/consumers HTTP/1.1[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Host: 192.168.0.3:8243[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Content-Length: 38[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept: application/json[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Origin: https://localhost:9443[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36[\r][\n]"
[2017-07-20 10:20:25,584] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Authorization: Bearer 50d9345d-2c36-3cd7-a777-d94038538735[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Content-Type: application/json[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Referer: https://localhost:9443/store/apis/info?name=SpringConsumer&version=1.0.0&provider=admin&tenant=carbon.super[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "Accept-Language: en-US,en;q=0.8[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "[\r][\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "{[\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "  "mobile_phone_num": "1234567890"[\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "}"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "POST /consumer_api/v1/consumers HTTP/1.1[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Origin: https://localhost:9443[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Accept: application/json[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Referer: https://localhost:9443/store/apis/info?name=SpringConsumer&version=1.0.0&provider=admin&tenant=carbon.super[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Accept-Language: en-US,en;q=0.8[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Host: consumer.lvh.me:3000[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Connection: Keep-Alive[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "[\r][\n]"
[2017-07-20 10:20:25,589] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "26[\r][\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "{[\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "  "mobile_phone_num": "1234567890"[\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "}[\r][\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "0[\r][\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "[\r][\n]"
[2017-07-20 10:20:25,640] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "HTTP/1.1 400 Bad Request[\r][\n]"

UPDATE - RESOLVED 更新-已解决

My endpoint didn't like chunked requests. 我的端点不喜欢分块的请求。 Had to update the sequence file with: 必须使用以下命令更新序列文件:

<property name="FORCE_HTTP_1.0" value="true" scope="axis2" />
<property name="DISABLE_CHUNKING" value="true" scope="axis2" />

And now it works. 现在就可以了。

As you can see in the wire log, APIM sends the json to the backend and it returns a 400. 如您在连线日志中所见,APIM将json发送到后端,并返回400。

Inbound request body: 入站请求正文:

[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "{[\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "  "mobile_phone_num": "1234567890"[\n]"
[2017-07-20 10:20:25,585] DEBUG - wire HTTPS-Listener I/O dispatcher-2 >> "}"

Outbound request body: 出站请求正文:

[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "{[\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "  "mobile_phone_num": "1234567890"[\n]"
[2017-07-20 10:20:25,590] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "}[\r][\n]"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM