在看到谷歌內容api中的文檔后,我試圖發送請求,每件事看起來都是正確的https://www.googleapis.com/content/v2.1sandbox/myid/orders/orderid/returnRefundLineItem但谷歌回應了 400 錯誤請求“格式錯誤的請求”導致了一個400 Bad Request.谷歌內容 API 響應:{ "error": { "errors": [ { "domain": "content.ContentErrorDomain", "reason": "malformed_request", "message": "Malformed request" } ], "code": 400, "message": "Malformed request" }}這是我的請求正文{ "operationId": "operation-6f8fa23bce94444b87e", "lineItemId": "QGKPTRMCKNCZESI", "quantity": 10, "reason": "other", "reasonText": "other", "priceAmount": { "value": "4500.00", "currency": "EUR" }, "taxAmount": { "value": "0.00", "currency": "EUR" }}將執行 guzzle 請求的函數 public function execute($api, $requestType = 'GET', $body = null) { $client = new \GuzzleHttp\Client(); $token = $this->container->get('config')->findOneByCode($this->configCode); $token = $token->getOptions(); $requestOptions = ['headers' => ['Authorization' => 'Bearer ' . $token, 'Content-Type' => 'application/json', 'Accept' => 'application/json']]; if (null !== $body) { $requestOptions = array_merge($requestOptions, ['body' => $body]); } $response = $client->request($requestType, $this->url . '/' . $this->merchant_id . '/' . $api, $requestOptions); if ($response->getStatusCode() === 200) { return (string)$response->getBody(); } return false; }
1 回答

呼啦一陣風
TA貢獻1802條經驗 獲得超6個贊
我通過使用另一個退款功能 createrefundinvoice解決了我的問題
因為我使用“enableOrderinvoices”創建了訂單:true
設置 "enableOrderinvoices": false 將解決問題
- 1 回答
- 0 關注
- 197 瀏覽
添加回答
舉報
0/150
提交
取消