在命令行用curl调试Push API v3接口出现errorcode1002

restapi
标签: #<Tag:0x00007fb83d16aad8>

(smallbird) #1

极光大神:
在命令行用curl调试Push API v3接口出现errorcode1002,我是直接从https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/拷贝出来的示例调用命令,只是把示例中的AppKey和MasterSecret改成我自己的而已。

curl --insecure -X POST -v https://api.jpush.cn/v3/push 
-H "Content-Type: application/json" 
-u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" 
-d '{"platform":"all","audience":"all",
"notification":{"alert":"Hi,JPush !",
"android":{"extras":{"android-key1":"android-value1"}},
"ios":{"sound":"sound.caf","badge":"+1","extras":{"ios-key1":"ios-value1"}}}}'

调用后返回的完整错误信息如下:

* upload completely sent off: 174 out of 174 bytes
* schannel: client wants to read 16384 bytes
* schannel: encdata_buffer resized 17408
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: encrypted data got 405
* schannel: encrypted data buffer: offset 405 length 17408
* schannel: decrypted data length: 327
* schannel: decrypted data added: 327
* schannel: decrypted data cached: offset 327 length 16384
* schannel: encrypted data buffer: offset 0 length 17408
* schannel: decrypted data buffer: offset 327 length 16384
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 327
* schannel: decrypted data buffer: offset 0 length 16384
< HTTP/1.1 400 BAD REQUEST
< Server: nginx
< Date: Sat, 09 Sep 2017 01:42:21 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Rate-Limit-Limit: 600
< X-Rate-Limit-Remaining: 599
< X-Rate-Limit-Reset: 60
< X-JPush-MsgId:
<
{"error": {"message": "Missing parameter", **"code": 1002**}}* Connection #0 to host api.jpush.cn left intact

#2


(smallbird) #3

我是直接用你们示例的指令通过curl来执行的,只是修改了APPKEY和MASTERSECRET,不是通过代码,能先确认下你们自己的示例指令有没有问题?谢谢。


#4
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 121.46.20.48...
* TCP_NODELAY set
* Connected to api.jpush.cn (121.46.20.48) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=CN; ST=GuangDong; L=Shenzhen; O=Shenzhen HeXunHuaGu Information Technologies Co.Ltd; CN=*.jpush.cn
*  start date: Jul 17 00:00:00 2017 GMT
*  expire date: Jul 16 23:59:59 2020 GMT
*  issuer: C=US; O=GeoTrust Inc.; CN=GeoTrust SSL CA - G3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Server auth using Basic with user '7d431e42dfa6a6d693ac2d04'
* Using Stream ID: 1 (easy handle 0x55dee87b2da0)
> POST /v3/push HTTP/1.1
> Host: api.jpush.cn
> Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==
> User-Agent: curl/7.52.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 204
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 200 
< server: nginx
< date: Tue, 12 Sep 2017 02:38:06 GMT
< content-type: application/json
< x-rate-limit-limit: 600
< x-rate-limit-remaining: 599
< x-rate-limit-reset: 60
< x-jpush-msgid: 1910537317
< 
* Curl_http_done: called premature == 0
* Connection #0 to host api.jpush.cn left intact
{"sendno":"0","msg_id":"1910537317"}‘

这是我们的测试结果,请你自己检查你的使用方法。