extraHeaders in REST Client

mnicklass
New Member
1 0 0

Hello everyone,

I am trying to provide extraHeaders in the Shopify REST Client, when I do requests, to verify the call at my HTTPS endpoint. For some reason it dosen't work though. I am fairly new to JS and Shopify, so if someone could maybe help me out, I would appreciate it. 

 

const extraHeaders = {
    headers:
        {'Server-Authentication': 'xxxxxxxxxx'}
};

export async function createWebhook(shop, token) { 
    const baseUrl = getBaseUrl(shop);
    const url = baseUrl+'/admin/api/2021-07/webhooks.json'; 
    
    const body = {
        "webhook": {
            "topic": "products/update",
            "address": "https://www.xxxxxxxxx.com/api/webhooks/",
            "format": "json"
          }
    }
    try{
        const client = new Shopify.Clients.Rest(shop, token);
        const result = await client.post({
            path: 'webhooks',
            data: body,
            type: DataType.JSON,
            extraHeaders: extraHeaders,
          });
          console.log(result);
          return result;
    }catch(err){
        console.error(`Error creating a new Webhook: `, err)
    }
    
}

 

Replies 0 (0)