Forum Discussion

russb's avatar
4 months ago

Access Denied

Hello

I am trying to GET a list of items.
I use the following code to successfully retrieve the company endpoints...

 

   sURL = "https://api.myob.com/accountright/[Company File GUID]"
   With objHTTP
    .Open "GET", sURL, False
    .setRequestHeader "Accept", "application/json"
    .setRequestHeader "Authorization", "Bearer " & gsMYOBToken
    .setRequestHeader "x-myobapi-key", idsMYOBClientId
    .setRequestHeader "x-myobapi-version", "v2"
    .setRequestHeader "x-myobapi-cftoken", fEncodeBase64(gsMYOBUsername & ":" & gsMYOBPassword)
    .setRequestHeader "Accept-Language", "en"
    .send
    resptext = .responseText
    End With

(note: the above works)

 

Using the same code with a new endpoint I get 'Access Denied'...

sURL = "https://api.myob.com/accountright/[Company File GUID]/Inventory/Item"

Can anyone offer what is missing or in error with the code to fix this issue?

 

Many thanks

Russ

  • For anyone interested, the following worked...

     

            .Open "GET", sURL, False
            .setRequestHeader "Accept", "application/json"
            .setRequestHeader "Authorization", "Bearer " & gsMYOBToken
            .setRequestHeader "x-myobapi-tenantid", gsMYOBTenantId
            .setRequestHeader "x-myobapi-version", "v2"
            .setRequestHeader "x-myobapi-key", idsMYOBClientId
            .send
            resptext = .responseText

    • Hi Russ, thanks. I have exactly the same problem. I can call some URLs, but on other typical GET endpoints I get access denied, despite following all the processes. Any idea what's going on with your change? Seems you've removed x-myobapi-cftoken and added a x-myobapi-tenantid (what's this?). Unsure why this would work, as docs suggest cftoken is required and this is the first time I have seen tenant id.

  • Confirming, that when I remove cftoken from the header, I can now access the endpoint I was trying to access (Sale/Invoice/Item/{invoiceId})
    Disappointing that the cftoken is documented and added as a layer of security but breaks the api call and works without.