Reputation: 197
I am trying to access Shopware 6 Management API by this Apps Scripts function: But I get Unsupported Media Type back. I don't understand why as I set the contentType according to here correctly. Has anybody an idea?
function setProductName(){
let url = CONFIG.url+"/api/product/" + "007f477135584b3c95f9437c4a9fc1ba"
Logger.log(url)
var payload = JSON.stringify({
"data": {
"name":"API test",
}
});
var auth_token = getAuthenticationToken();
let options = {
"method": "GET",
"contentType": "application/json",
"headers": {
"Authorization": "Bearer " + auth_token,
"Content-Type": "application/json",
},
//"payload":payload,
"muteHttpExceptions": false
};
req = UrlFetchApp.getRequest(url, options)
Logger.log(req)
let response = UrlFetchApp.fetch(url, options);
let responseData = JSON.parse(response.getContentText());
Logger.log(responseData)
return responseData;
}
Upvotes: 1
Views: 162
Reputation: 197
After some hours of searching, I found that the solution is to set the Accept Header too:
"headers": {
"Accept":"application/json",
"Authorization": "Bearer " + auth_token
},
Upvotes: 2