会员 API 仅在 walmart.io "Try API" 页面上工作,但不是每个 curl 请求

Affiliate API work only over walmart.io "Try API" page, but not per curl request

你好附属API支持团队,

我开始实现与 Affiliate API 的连接。

首先,我测试了 "Taxonomy" 和 "Paginated Items" 入口点。 当我通过 walmart.io 尝试 API 页面请求时,通过所需的 headers 然后一切正常,我得到了预期的响应。

但是,当我在笔记本电脑上使用 curl 命令执行相同的请求并传递相同的 headers 和参数时,我收到错误响应

有关详细信息,请参阅下面的调试日志。

请指教

此致问候并提前致谢

塞尔吉


日志:分页项

curl --verbose --compressed  -H "WM_CONSUMER.ID:X-removed-X"  -H "WM_CONSUMER.INTIMESTAMP:1583698692666"  -H "WM_SEC.KEY_VERSION:2"  -H "WM_SEC.AUTH_SIGNATURE:IBVm1uz8+6uNA6XwJjweUjJRBHavUPCNoTXf6aino0uDN1DWFfSpaZRd+aVeoxdKZKZ2b/fC/gAcZoaBAqD4s6GaqO719d3E//EfLiRUPPB0AxKgpmB2/E6mlv5BPz3Zuds8aubPgruOaDJG8GjbLF4pxsV2AbLTgBV8/XSc2N7RSl/Sv4xyC2YIENRYn+Xclt7seScNq+5tlhvPtXTBCYQ02ocrJJ+TbOcMFNrIhQicQ6nLi/yIvPXjptPLLfYKrJI29AqWaHN1+mEdVK8NhqF8WEAPO897I7eVgTIw76A6XzKgwexf9irSRbjW88UbBsxMTS/xbvZNg51GYMl8YA=="  -H "Accept:application/json"  "https://developer.api.walmart.com/api-proxy/service/affil/product/v2/items"
*   Trying 104.90.152.88...
* TCP_NODELAY set
* Connected to developer.api.walmart.com (104.90.152.88) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (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 handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=Arkansas; L=Bentonville; O=Wal-Mart Stores, Inc.; CN=prod.walmart.com
*  start date: May 17 17:01:36 2019 GMT
*  expire date: May 17 17:01:36 2020 GMT
*  subjectAltName: host "developer.api.walmart.com" matched cert's "developer.api.walmart.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2
*  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
* Using Stream ID: 1 (easy handle 0x56172ba6f6b0)
> GET /api-proxy/service/affil/product/v2/items HTTP/2
> Host: developer.api.walmart.com
> User-Agent: curl/7.58.0
> Accept-Encoding: deflate, gzip
> WM_CONSUMER.ID:X-removed-X
> WM_CONSUMER.INTIMESTAMP:1583698692666
> WM_SEC.KEY_VERSION:2
> WM_SEC.AUTH_SIGNATURE:IBVm1uz8+6uNA6XwJjweUjJRBHavUPCNoTXf6aino0uDN1DWFfSpaZRd+aVeoxdKZKZ2b/fC/gAcZoaBAqD4s6GaqO719d3E//EfLiRUPPB0AxKgpmB2/E6mlv5BPz3Zuds8aubPgruOaDJG8GjbLF4pxsV2AbLTgBV8/XSc2N7RSl/Sv4xyC2YIENRYn+Xclt7seScNq+5tlhvPtXTBCYQ02ocrJJ+TbOcMFNrIhQicQ6nLi/yIvPXjptPLLfYKrJI29AqWaHN1+mEdVK8NhqF8WEAPO897I7eVgTIw76A6XzKgwexf9irSRbjW88UbBsxMTS/xbvZNg51GYMl8YA==
> Accept:application/json
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 400 
< accept-ranges: bytes
< content-encoding: gzip
< content-type: application/json;charset=utf-8
< last-modified: Sun, 08 Mar 2020 20:19:03 GMT
< strict-transport-security: max-age=86400
< x-lua-strict-transport-security: max-age=86400
< x-tb: 1
< x-tb-optimization-total-bytes-saved: 0
< wm_svc.env: prod
< wm_svc.name: affil-product
< wm_svc.version: 2.0.0
< date: Sun, 08 Mar 2020 20:19:03 GMT
< vary: Accept-Encoding
< set-cookie: TS01a35e2a=0130aff2324e25bae12799c8f4cf8c303c61b5b1e4b3a9b49b2dc40cd4190d5006c5aeff01fd85aab36fc6024d1cb0b15e79ae0780; Path=/; Secure
< 
* Connection #0 to host developer.api.walmart.com left intact
{"errors":[{"code":4008,"message":"Missing itemId"}]}


日志:分类法

curl --verbose --compressed \
>  -H "WM_CONSUMER.ID:X-removed-X" \
>  -H "WM_CONSUMER.INTIMESTAMP:1583631173218" \
>  -H "WM_SEC.KEY_VERSION:2" \
>  -H "WM_SEC.AUTH_SIGNATURE:fJ0gfijP2k/Jp8L96xHmJvpHvhVohanxa7f+dzewuvh73jceaoEvpRTZfsybss4Sdn7Ytx7vk/l4k411tb1v6lLfIam8YhNW8niiO9MUxhdd7gjWDXhdsTTSnDrx4vy3eQtIetyz413APz1VZAKCViRJvqE4rh0JETMeY5vtEl6wgjyp1YgMol/t0+mz8y5n9wu4KlBVcE6D3yUxNNPGPzjKAVpxmQTsuw9Lp0awfLhArT74xXdfDUPGoJ72b09MVUtJ0pQsZoYY7WXybUgE2A6vtm80nqzQFEGVWVWoyfVtz0zPvaimQYklkLwUUrW8QimCFWCrpUDBwWVgPptKNQ==" \
>  -H "Accept:application/json" \
>  "https://developer.api.walmart.com/api-proxy/service/affil/product/taxonomy"
*   Trying 104.90.152.88...
* TCP_NODELAY set
* Connected to developer.api.walmart.com (104.90.152.88) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (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 handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=Arkansas; L=Bentonville; O=Wal-Mart Stores, Inc.; CN=prod.walmart.com
*  start date: May 17 17:01:36 2019 GMT
*  expire date: May 17 17:01:36 2020 GMT
*  subjectAltName: host "developer.api.walmart.com" matched cert's "developer.api.walmart.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Organization Validation CA - SHA256 - G2
*  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
* Using Stream ID: 1 (easy handle 0x557c4ef856b0)
> GET /api-proxy/service/affil/product/taxonomy HTTP/2
> Host: developer.api.walmart.com
> User-Agent: curl/7.58.0
> Accept-Encoding: deflate, gzip
> WM_CONSUMER.ID:X-removed-X
> WM_CONSUMER.INTIMESTAMP:1583631173218
> WM_SEC.KEY_VERSION:2
> WM_SEC.AUTH_SIGNATURE:fJ0gfijP2k/Jp8L96xHmJvpHvhVohanxa7f+dzewuvh73jceaoEvpRTZfsybss4Sdn7Ytx7vk/l4k411tb1v6lLfIam8YhNW8niiO9MUxhdd7gjWDXhdsTTSnDrx4vy3eQtIetyz413APz1VZAKCViRJvqE4rh0JETMeY5vtEl6wgjyp1YgMol/t0+mz8y5n9wu4KlBVcE6D3yUxNNPGPzjKAVpxmQTsuw9Lp0awfLhArT74xXdfDUPGoJ72b09MVUtJ0pQsZoYY7WXybUgE2A6vtm80nqzQFEGVWVWoyfVtz0zPvaimQYklkLwUUrW8QimCFWCrpUDBwWVgPptKNQ==
> Accept:application/json
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 403 
< accept-ranges: bytes
< content-encoding: gzip
< content-type: application/json;charset=utf-8
< last-modified: Sun, 08 Mar 2020 20:20:57 GMT
< strict-transport-security: max-age=86400
< x-lua-strict-transport-security: max-age=86400
< x-tb: 1
< x-tb-optimization-total-bytes-saved: 0
< date: Sun, 08 Mar 2020 20:20:57 GMT
< vary: Accept-Encoding
< set-cookie: TS01a35e2a=0130aff232c50989262fcf9c5dfdc5de56262db0064892983ed98e2f5be77b65d62dcaa0db55c2386de3ea7190f7e3ff64099280bb; Path=/; Secure
< 
* Connection #0 to host developer.api.walmart.com left intact
{"details":{"Description":"Unable to retrieve service related information, please read documentation for mandatory headers or URI specification"}}

在此聊天室中找到解决方案: https://gitter.im/IO-support/community

文档不是最新的/令人困惑 -

  1. 您的 second URL 应该用于 API 的 V2 - 在这种情况下,https://developer.api.walmart.com/api-proxy/service/affil/product/v2/taxonomy

  2. 你的first URL确实是V2,但是输入参数的名称不同-看this page对于正确的输入 - 你应该传递强制性的 ids 参数。