cLink = "https://site/api/v2/products/"+alltrim(cCode)+"?search=sku&token=token"
MsgRun( cLink, "READING FORUM PAGE", { || uResponse := WebPageContents( cLink, .t. ) } )
Now the new site is giving a :
"message":"Unauthorized"
I tried a sample from Tim : (changed real token to text token just for forum )
I don't know with data is needed in cData ? Tim ??
If I use the API on there test site, it works, and I get this information :
curl -X GET "https://site/v3/products/inventory?catalog_reference=B10" -H "accept: application/json" -H "x-site-authorization: token" -H "x-api-key: apikey here"
Tim's code (Thanks)
- Code: Select all Expand view RUN
local cUrl := "https://siteo/v3/products/inventory?catalog_reference=Gi6400B?token=token"
local cData := ""
local cContentType := "application/json"
local cAuthorization := cToken // cToken is only the token and not "x-site-authorization: token" ??? is this the issue ?
PostTo360( cUrl, cData, cContentType,cAuthorization )
Function PostTo360( cUrl, cData, cContentType,cAuthorization )
Local oOle,cRet:='',uRet
default cContentType:="application/json"
default cAuthorization:=""
oOle := CreateObject( "MSXML2.XMLHTTP" )
oOle:Open( 'GET', cUrl, .f. )
oOle:SetRequestHeader( "Content-Type", cContentType)
oOle:SetRequestHeader( "Authorization",cAuthorization)
oOle:Send( cData )
cRet := oOle:ResponseBody
msginfo(cRet)
RETURN( cRet )