function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suraj SinghSuraj Singh 

Salesforce - One Drive integeration Error

Hi All,
Whenever we make a request to Microsoft one drive, it will always throws the 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": "8b4202bd-d0db-4c2f-9c0a-9186aae3f6ee", "date": "2017-05-01T17:20:30" } } }
Now the strange thing is that,
When we made a request to create a folder or upload a file on one-Drive, if will done successfully but the response is still same, Since response was not correct, so we are unable to know is folder created or not?, what was the id of created folder?
Here is the code that we are using to get USER.
    Http h = new Http();
	HttpRequest req = new HttpRequest();	
	req.setMethod('GET');
	req.setHeader('Authorization', 'Bearer ' + accessToken);
	req.setEndpoint('https://graph.microsoft.com/v1.0/users');
	HttpResponse res;
	try {
		res = h.send(req);
		System.debug('HTTP Response Code: ' + res.getStatusCode());
		System.debug('Response Body: ' + res.getBody());
	} catch (Exception e) {
		System.debug('Callout Error:' + e.getMessage());            
	}
Thank you.
 
Daniel BallingerDaniel Ballinger
Try explicitly setting the MIME type for the request.
 
req.setHeader('Content-Type', 'application/json');
You will need to check what Content-Type's the request supports.
 
Suraj SinghSuraj Singh
@Daniel Ballinger, We have checked the content type. but it will throws the same error.