Getting StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.Stream
Hi I am trying to connect Box.com with MS Dynamics CRM.
Currently i am trying to automate generation of Token automatically by using this code.
HttpClient client= new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.box.com/oauth2/token");
request.Content = new FormUrlEncodedContent(new Dictionary {
{ "client_id", "fcsp8sfkad9pnju0vycv8icyky5sc5gc" },
{ "client_secret", "ocftC94EsFv8ePN2xMJutZsYI9TqtbLE" },
{ "grant_type", "client_credentials" }
});
CancellationToken tc = new CancellationToken();
var response = await client.SendAsync(request, tc);
response.EnsureSuccessStatusCode();
var payload = JObject.Parse(await response.Content.ReadAsStringAsync());
var token = payload.Value("access_token");
But always i am getting error after deploying this code.
"
StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Accept-Encoding
Cache-Control: no-store
Date: Tue, 12 Sep 2017 05:04:54 GMT
Set-Cookie: box_visitor_id=59b76af69361c3.34809942; expires=Wed, 12-Sep-2018 05:04:54 GMT; Max-Age=31536000; path=/; domain=.box.com; secure
Set-Cookie: bv=OPS-41967; expires=Tue, 19-Sep-2017 05:04:54 GMT; Max-Age=604800; path=/; domain=.app.box.com; secure
Set-Cookie: cn=5; expires=Wed, 12-Sep-2018 05:04:54 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure
Set-Cookie: site_preference=desktop; path=/; domain=.box.com; secure
Server: Server
Age: 0
Connection: keep-alive
Content-Length: 99
Content-Type: application/json
"
Please sign in to leave a comment.
Comments
0 comments