【发布时间】:2021-12-31 06:23:00
【问题描述】:
我使用 powershell 从 shopify 获取流并将其转换为 json 可读文本。 它工作了几个星期,但现在没有返回相同的数据格式。
$uri = "https://yourshop.myshopify.com/admin/api/2021-10/orders.json?limit=250"
$apikey = ""
$password = ""
$headers = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($apikey+":"+$password))}
$products = Invoke-RestMethod -Uri $uri -FollowRelLink -contentType "application/json" -Method Get -Header $headers -Body $Body -MaximumFollowRelLink 5
$products | ConvertTo-Json -Depth 5 | Out-File C:\json\ordersdepth5.json -encoding utf8
它曾经返回整洁的 json
{
"orders": [
{
"id": 4059713634402,
"admin_graphql_api_id": "gid://shopify/Order/4059713634402",
"app_id": 580111,
"browser_ip": "120.154.83.138",
"buyer_accepts_marketing": true,
"cancel_reason": null,
"cancelled_at": null,
但现在它返回了
["{\"orders\":[{\"id\":4122462257250,\"admin_graphql_api_id\":\"gid:\\/\\/shopify\\/Order\\/4122462257250\",\"
一堆斜线和垃圾
数据流有问题吗?我应该看什么。
除非有 api 更改,否则 Shopify 不会更改格式?
【问题讨论】:
标签: json powershell