我正在使用powershell从shopify获取一个流,并将其转换为可读文本。它正常工作了几个星期,但现在不能返回相同的数据格式。
$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\",\"一堆斜杠和垃圾
数据流有问题吗?我应该看什么?
Shopify不会更改格式,除非有api更改?
发布于 2021-11-21 07:19:28
我修复了这个问题,将数据移动到powershell中进行转换,然后转换为json。
$products | ConvertFrom-Json -AsHashtable | ConvertTo-Json -Depth 5 -Compress |Out-File C:\json\ordersdepth2.json -encoding utf8https://stackoverflow.com/questions/70052426
复制相似问题