繁体   English   中英

WSO2 API管理器POST正在剥离JSON

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

我碰到了端点,但API管理器似乎在到达JSON之前就剥离了JSON,因此它始终为空。 我将其设置为后期制作和使用的application / json。 我真的只是希望能够将JSON转储到请求正文中,并将其传递到我的端点而无需进行转换。 我的摇摇欲坠文件:

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

和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'

和电汇:

[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]"

更新-已解决

我的端点不喜欢分块的请求。 必须使用以下命令更新序列文件:

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

现在就可以了。

如您在连线日志中所见,APIM将json发送到后端,并返回400。

入站请求正文:

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