Forum Discussion
unauthorised seems to suggest it is well formed but has something to do with key or token...have you encoded it correctly..I recall I had a similar issue and needed to escape data string to get it going...sorry dont recall exactly what I did
what the url you are querying? put in the full route
here is my get request from the NET SDK from a trace in Fiddler. This works.
I would;
1. Get rid of Cache control header
2. Get rid of Accept header
3. Modify Accept-Encoding to only include gzip
4. Get rid of Connection header
I can't promise that will make any difference but I have had issues where otherwise harmless headers have prevented me fro getting it working. As you can see this is from the .NET SDK. I have a restsharp client that contructs it as well but I dont have the trace for it here. If you are still stuck afte rthis then reply and I'll get it to you and you can compare then
GET https://arl2.api.myob.com/accountright/f173[TRUNCATED]aa/Payroll/PayrollCategory/Wage/ HTTP/1.1 Authorization: Bearer AAEAAEX[TRUNCATED]CclRjZRxLZM Accept-Encoding: gzip User-Agent: MYOB-ARL-SDK/2022.6.425 (+http://developer.myob.com/api/accountright/v2/) x-myobapi-key: xdf[TRUNCATED]dye x-myobapi-version: v2 x-myobapi-cftoken: QWRt[TRUNCATED]N0Wjgj Host: arl2.api.myob.com
- 6magics3 years agoContributing User
I just tried removing those headers but had no luck.
I have not personally encoded any of the keys or tokens except for the x-myobapi-cftoken containing the credentials which is b64 encoded. I'm not sure if the python requests module automatically applies and encoding scheme but I haven't run into any issues with that when requesting other APIs.
An example request that I've been using is:
GET: https://ar1.api.myob.com/accountright/{{company_file_id}}/Sale/Invoice/Service
- kjm3 years agoTrusted Cover User
Asking the obvious: have you actually got permission to login to the file online using the user credentials you are sending??
install Fiddler and capture your request and see what is getting sent exactly. Your example is your call from your code. Capture the actual request and examine that. From there you can start to see what is going wrong. My example is capture from Fiddler and shows a successful call
6magics
Here is a call from RestSharp .NET library which is just a lib around a httpclient to simplify calls to APIGET https://api.myob.com/accountright//f173ad4{TRUNCATED}aaa/Sale/Invoice HTTP/1.1 authorization: Bearer AA{TRUNCATED}3TWg-WJ x-myobapi-cftoken: QWRt{TRUNCATED}Wjgj x-myobapi-key: xd{TRUNCATED}ye x-myobapi-version: v2 Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml User-Agent: RestSharp/108.0.2.0 Host: api.myob.com Accept-Encoding: gzip
I am Base64Encoding the cftToken
Looking for something else?
Search the Community Forum for answers or find your topic and get the conversation started!
Find technical support and help for all MYOB products in our online help centre
Dig into MYOB Academy for free courses, learning paths and live events to help build your business with MYOB.