ImportJSON
ImportJSON copied to clipboard
Need to add http header referer: origin
Hi @bradjasper , I need to add http headers : referer in order to access data from some API.
var options = { 'headers' : { 'referer' : 'origin' } };
I tried a simple script a simple script and it works
var options = { 'headers' : { 'referer' : 'origin' } }; var response = UrlFetchApp.fetch("https://shopee.co.id/api/v2/search_items/?by=pop&limit=10&match_id=42361077&newest=0&order=desc&page_type=shop&version=2", options);
I tried to include it into your code, but it returns error. Do I need to change it into "options2" or you have another solutions? Thanks in advance
My implementation of ImportJson supports http headers. The function call for your example would look something like this:
=IMPORTJSONAPI("https://shopee.co.id/api/v2/search_items/?by=pop&limit=10&match_id=42361077&newest=0&order=desc&page_type=shop&version=2", "$.items[*]", "itemid, name", "headers={ 'referer' : 'origin' }")