The Elearning Community • API connection error [solved]
Page 1 of 1

API connection error [solved]

Posted: Wed Aug 14, 2013 8:31 pm
by martin.duran
Hi, i'm trying to make a call to the REST API from C#, but i always receive this message:

Code: Select all

{"success":false,"error":104,"message":"Authorization header value doesn't match"}
The X-Authorization hash is well generated (Y2x6RVIwYTRCWkdBZnBKRiFCX2VobFRTOjhkZmVjODcxOWYwZjQ1ZjY4ZGVjNGNmMDA2ODI4MzI2OTQ4ZmQ2MmU=). This is the code i use to make the call:

Code: Select all

string url = String.Format("http://{0}/api/{1}", urlBase, method); 
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 
request.Method = "POST"; 
request.Host = urlBase; 
request.Headers.Add("X-Authorization", "Docebo " + code); 
request.ContentType = "text/json"; 

StreamWriter requestStream = new StreamWriter(request.GetRequestStream()); 

urlBase = 
method = user/checkUsername 
json = {"userid": "user.test"}
Anyone has any idea why i'm receiving this message? Or any C# example.

Thanks in advance!

Re: API connection error

Posted: Wed Aug 14, 2013 10:18 pm
by max
Hi Martin
Welcome on board!
Sorry, but our Tech Guys are all on holiday, I am not able to support you on this issue.
Hope someone else on the forum is available.

Re: API connection error

Posted: Fri Aug 16, 2013 3:12 pm
by martin.duran
Hi, i finally got it worked! Just set the ContentType to "application/x-www-form-urlencoded" and the content that is written to the stream like GET format: param1=value1&param2=value2...


Re: API connection error [solved]

Posted: Fri Aug 16, 2013 3:20 pm
by max
thanks to you, Martin, you did everything by yourself... :-)

Thanks for posting the solution, too!

This site uses cookies.

Some of the cookies we use are essential for parts of the site to operate and have already been set. We also use Google Analytics scripts, which all use cookies.
You may delete or block all cookies from this site in your browser options.