I have created a named credential that points to the Microsoft graph API.

My credential has been authenticated successfully but when I try to use it from Apex it fails. I am unable to debug , The code I am using is :

HttpRequest req = new HttpRequest();
req.setHeader('Content-Type', 'application/x-www-form-urlencoded');
Http http = new Http();
HTTPResponse res = http.send(req);

I am getting the below error:

08:19:50:598 USER_DEBUG [7]|DEBUG|<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>Request_BadRequest</m:code><m:message xml:lang="en">The MIME type 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2,application/json;odata=minimalmetadata;q=0.001' requires a '/' character between type and subtype, such as 'text/plain'.</m:message></m:error>

1 Answer 1


I had the same issue and managed to solve it by adding


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.