ImportJSON icon indicating copy to clipboard operation
ImportJSON copied to clipboard

Need to add http header referer: origin

Open mariopattan opened this issue 4 years ago • 1 comments

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

mariopattan avatar Apr 16 '20 07:04 mariopattan

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' }")

qeet avatar Apr 16 '20 15:04 qeet