簡體   English   中英

Shopify GET webhooks請求

[英]Shopify GET webhooks requests

我正在嘗試獲取我們在Private APP中使用的所有webhooks,如下所示:

request.get({
    url: `https://${shop}.myshopify.com/admin/webhooks.json`,
    oauth: {
        oauth_token: accessToken
    }
}, (error, response, body) => {
    const webhook = JSON.parse(body)
    if (response.statusCode === 200) {
        resolve.json({ webhook, status: 201 })
    } else {
        resolve.json({ error: 'Did not get list of webhooks', status: 500, response: response, err: error })
    }
    reject('Could not get customer activation URL')
})

但是,當我嘗試返回數據時出現錯誤500。

那不是結構正確的電話。 Shopify API調用中的任何API端點都沒有oauth參數。 而是使用通過與標頭中的API進行oAuth交換來使用頒發給您的令牌。 該API將使用您用於生成令牌的API密鑰向您返回在商店中產生的Webhook。

根據Shopify的示例代碼...

const shopRequestUrl = 'https://' + shop + '/admin/webhooks.json';
const shopRequestHeaders = {
  'X-Shopify-Access-Token': accessToken,
};

request.get(shopRequestUrl, { headers: shopRequestHeaders })
  .then((shopResponse) => {
  res.end(shopResponse);
})
.catch((error) => {
  res.status(error.statusCode).send(error.error.error_description);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM