You need to sign in to do that
Don't have an account?
Suraj Singh
ERROR: Integrating Salesforce to one-Drive.
Response code: 400
Error, { "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "822a994e-6ef7-4c4c-bd27-5b96186165f0", "date": "2017-04-13T13:44:15" } } }
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Authorization', 'Bearer '+ accessToken);
req.setEndpoint('https://graph.microsoft.com/v1.0/me/drive/root');
HttpResponse res = h.send(req);
Error, { "error": { "code": "BadRequest", "message": "The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' requires a '/' character between type and subtype, such as 'text/plain'.", "innerError": { "request-id": "822a994e-6ef7-4c4c-bd27-5b96186165f0", "date": "2017-04-13T13:44:15" } } }
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Authorization', 'Bearer '+ accessToken);
req.setEndpoint('https://graph.microsoft.com/v1.0/me/drive/root');
HttpResponse res = h.send(req);
@VivekShinde
It doesn't work,
Problem is not the content-type, problem is thatm if you use any rest api client (like ARC), it will works fine.
Although it works in JS, when we made a request from JS on VF page, it works.
But only in Apex code it does not work.
Actually, header is an optional for it. if you try it without header it will also work perfect.
It will only work in JS or on any rest api client (like ARC).