Forum Discussion

russb's avatar
russb
Member
1 year 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

3 Replies

  • 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

  • rohank4's avatar
    rohank4
    Member
    1 year ago

    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.

Looking for something else?

Search the Community Forum for answers or find your topic and get the conversation started!

Community home

Learn:

 

Level up your skills using MYOB software.

 

Find help guides and technical solutions for all MYOB products here

Explore video tutorials for our software at the MYOB Academy here

 

Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.