Using Bit.ly V4 API via this code:
HttpRequest req2 = new HttpRequest();
req2.setEndpoint('https://api-ssl.bitly.com/v4/shorten');
req2.setMethod('POST');
req2.setHeader('Authorization', 'Bearer ...');
String jsonBody = '{"long_url":"https://test.com"}';
req2.setBody(jsonBody);
req2.setHeader('Content-Type', 'application/json');
Http http2 = new Http();
HttpResponse res2 = http2.send(req2);
system.debug(res2);
yields the following response:
CALLOUT_RESPONSE [24] | System.HttpResponse [Status = Not Acceptable, StatusCode = 406]
The same request works in Postman. Why doesn't it work in Apex?