I'm trying to create products in Shopify with their API through a google sheet. Whenever I try to create an HTTP request I get the following error:
"Login information disallowed"
To test the API, I created a more or less identical python script. When I run the Python script the product gets created as planned. But I just can't get it to work through my google sheet.
GOOGLE SCRIPT CODE (NOT WORKING) :
function create_product() {
var url = "https://XXXX:XXXX@XXXX.myshopify.com/admin/api/2019-04/products.json";
var data = {
"product": {
"title": 'test 1',
"body_html": 'test 1',
"vendor": 'test 1',
"product_type": 'test 1',
"tags" : 'test 1'
}
};
var params = {
method : 'POST',
contentType : 'application/json',
payload : JSON.stringify(data),
};
var post = UrlFetchApp.fetch(url, params);
}
PYTHON CODE:
import requests
url = "https://XXXX:XXXX@XXXX.myshopify.com/admin/api/2019-04/products.json"
data = {
"product": {
"title": 'test 1',
"body_html": 'test 1',
"vendor": 'test 1',
"product_type": 'test 1',
"tags" : 'test 1'}
}
post = requests.post(url=url, json=data)
I expected both scripts to give me the same results, but only the Python script seems to work. The "Login information disallowed" error keeps showing up in the google script, when i try to do the http post.