Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

MyOB Account Right API and Dynamics CRM

Posted on by 480

Hi everyone,

I am working on Dynamics CRM integeration with MyOB Accounright (Live API) and I am not able to get OAUTH TOKEN from their API.

For each and every request it says "Invalid request" whereas I am sending the message/request in the format given on their developer portal and enclosing all the require headers/parameters.

Can someone help ? I already  got the access code but need to get OAUTH ACCESS TOKEN.

I am using Online/Cloud based file and need to obtain it for the same.

Below is my C# code.

 string baseUrl = "secure.myob.com/.../authorize";
           

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseUrl);

                    // We want the response to be JSON.
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    // Build up the data to POST.
                    List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();
                    postData.Add(new KeyValuePair<string, string>("grant_type", "authorization_code"));
                    postData.Add(new KeyValuePair<string, string>("client_id", clientId));
                    postData.Add(new KeyValuePair<string, string>("client_secret", clientSecret));

                    postData.Add(new KeyValuePair<string, string>("scope", "CompanyFile"));
                    postData.Add(new KeyValuePair<string, string>("redirect_uri", "http://desktop"));
                    postData.Add(new KeyValuePair<string, string>("code", "UviY%21IAAAAC64WKiDpPhnUfp48i-WJAmaGrPDe4IhQUKSG90woCudAQEAAAFaYQZmCvVPVUPo4NysgvDzkQR2Xy6Bj2VWNAYlpC_xamLmcPs3Yw9Omw2_6ayPvEapdJYCQhHzRUDoGMrper1JD92jTs7jD1-ywmn6EmLdQnDBSbQGVD_ZN3UqRVtryE1LrDQbKgRF5mhTToqAClH_53qQLiD4enW3cyrmusa1rfx5vmZ5lqVNprUeyv3l6SyhF6b6vNuerqYvqSrLnNbpXSOnT5R9CKTbU5gKPa2Egp7Hm8Uw-4eF2FrEuU3FGXfvTHNpyPhwtzhQzVrNvUR1fzo02c3HRZaN01dfFHoBJucSWYFtT4-S7xm4HG8_TQCOLIPcLeZK-0c65ut7y1V_"));
                    FormUrlEncodedContent content = new FormUrlEncodedContent(postData);

                    // Post to the Server and parse the response.
                    HttpResponseMessage response = await client.PostAsync("authorize", content);
                    string jsonString = await response.Content.ReadAsStringAsync();
                    object responseData = JsonConvert.DeserializeObject(jsonString);

                    // return the Access Token.
                    return ((dynamic)responseData).access_token;
                }
            }

Reference URL (MyOB): 

http://developers.myob.com/api/accountright/api-overview/authentication/


Thanks in Advance.

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,219 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans