Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Woocommerce API in script automation

Topic Labels: Automations Integrations
438 0
cancel
Showing results for 
Search instead for 
Did you mean: 
SNQR
4 - Data Explorer
4 - Data Explorer

Hello,

First, sorry for my english.

I'm new in javascript development and i'm trying to update some product on my woocommerce website from airtable.

In the automation, i have a script where i try to retrieve a product, i use this code : 

 

 

const reponse = await fetch("https://website.com/wp-json/wc/v3/products/54188?consumer_key=ck_xxxxxxxx&consumer_secret=cs_xxxxxxxx",{
    "Method": "get",
    "Headers":{
        "Contant-Type" : "application/json"
    }    
});
return await console.log(reponse);

 

 

but i have a 403 error (Access Forbidden). When i put this "https://website.com/wp-json/wc/v3/products/54188?consumer_key=ck_xxxxxxxx&consumer_secret=cs_xxxxxxx... in the url, i have access to the product, i don't understand why i have a forbidden access with the script 😕 

So i tried to pu the authentification in the headers : 

 

 

const reponse = await fetch("https://website.com/wp-json/wc/v3/products/54188",{
    "Method": "get",
    "Headers":{
           "Authorization" : "ck_xxxxx:cs_xxxx",
           "Content-Type" : "application/json"
    }    
});
return await console.log(reponse);

 

 

but i have the same problem. 

 

The woocommerce API documentation is only for node.js / python etc, anyone already did it in vanilla javascript ?

0 Replies 0