Randomly started to get 400 "Invalid request" error: "The provided encoding is not supported."

Viewed 613

Starting around 00:10 UTC on Saturday 30th Jan 2021 we've started to see some of our cron jobs that update Microsoft shared calendar entries randomly return a 400 with the following error in the returned JSON contents:

'{ "error": { "code": "invalidRequest", "message": "The provided encoding is not supported." } }',

These appear randomly - if I rerun the command that created it there a good chance it will work just fine. Our cron job runs every hour (it's maintaining a share calendar of approved changes from our change management system) and the events it fails on appear to be different on every run.

Has something changed with Graph API over the weekend or are Microsoft's server experiencing heavy load? This seems like a really weird error message to get from an overloaded service though - I've gone down the rabbit hole of trying to work out what encoding it's talking about without any luck (especially as debugging is tricky because re-running calendar entry scripts by hand often works!). Searching for 'Microsoft Graph API "The provided encoding is not supported"' hasn't really thrown much up either so I'm a bit stumped now. Ideas anyone?

EDIT: The request is being made from a Perl script using LWP to PATCH to the https://graph.microsoft.com/v1.0/users/<user-id>/calendars/<calendar-id>. Here's an example of the dump of the object structure when we get the error (with the bearer key deleted obviously!). This contains everything being sent and everything being returned:

[69295] [Mon Feb  1 08:10:07 2021] [warning]: Event creation failed. LWP UA response object:
$VAR1 = bless( {
                 '_protocol' => 'HTTP/1.1',
                 '_content' => '{ "error": { "code": "invalidRequest", "message": "The provided encoding is not supported." } }',
                 '_rc' => 400,
                 '_headers' => bless( {
                                        'connection' => 'close',
                                        'client-response-num' => 1,
                                        'date' => 'Mon, 01 Feb 2021 08:10:07 GMT',
                                        'client-ssl-cert-issuer' => '/C=US/O=Microsoft Corporation/CN=Microsoft Azure TLS Issuing CA 01',
                                        'client-ssl-cipher' => 'ECDHE-RSA-AES128-GCM-SHA256',
                                        'client-peer' => '20.190.169.24:443',
                                        'strict-transport-security' => 'max-age=31536000',
                                        'content-length' => '95',
                                        '::std_case' => {
                                                          'client-response-num' => 'Client-Response-Num',
                                                          'client-ssl-cert-issuer' => 'Client-SSL-Cert-Issuer',
                                                          'client-ssl-cipher' => 'Client-SSL-Cipher',
                                                          'client-peer' => 'Client-Peer',
                                                          'strict-transport-security' => 'Strict-Transport-Security',
                                                          'client-date' => 'Client-Date',
                                                          'client-ssl-cert-subject' => 'Client-SSL-Cert-Subject',
                                                          'client-ssl-socket-class' => 'Client-SSL-Socket-Class'
                                                        },
                                        'client-date' => 'Mon, 01 Feb 2021 08:10:07 GMT',
                                        'content-type' => 'application/json',
                                        'client-ssl-cert-subject' => '/C=US/ST=WA/L=Redmond/O=Microsoft Corporation/CN=graph.microsoft.com',
                                        'client-ssl-socket-class' => 'IO::Socket::SSL'
                                      }, 'HTTP::Headers' ),
                 '_msg' => 'Bad Request',
                 '_request' => bless( {
                                        '_content' => '{"extensions":[{"@odata.type":"Microsoft.Graph.OpenTypeExtension","RTTicketId":"236595","extensionName":"uk.ac.lboro.lunet.RTTicketId"}],"body":{"content":"<a href=\'https://servicedesk.lboro.ac.uk/Changes/Normal.html?id=236595\'>Change details in RT</a>.<br><br><h2>Test</h2><h3>Risk Level: Low</h3>","contentType":"HTML"},"singleValueExtendedProperties":[{"value":"236595","id":"String {E6F70170-9BED-11E8-8CBC-CDC132C02D95} Name RTTicketId"}],"subject":"RT Ticket# 236595 Test (Drafting (draft))","showAs":"tentative","end":{"timeZone":"UTC","dateTime":"2021-01-29 17:00:00"},"start":{"timeZone":"UTC","dateTime":"2021-01-29 07:00:00"}}',
                                        '_uri' => bless( do{\(my $o = 'https://graph.microsoft.com/v1.0/users/8c0729fb-fdd8-4c47-afdd-6319d7f53527/calendars/AAMkADcyNzFmM2NmLTQwNWUtNDdkYi05NjBkLTMyY2Y0YWZmNjNjOABGAAAAAADLxa7s4pdTQYKigJvn9tIVBwCQ07ZtjCb-RJqL4KgdwIpWAAAA2V50AABdqLP0L9GOTKSkX7kyfyLXACFn_IIFAAA=/events/AAMkADcyNzFmM2NmLTQwNWUtNDdkYi05NjBkLTMyY2Y0YWZmNjNjOABGAAAAAADLxa7s4pdTQYKigJvn9tIVBwCQ07ZtjCb-RJqL4KgdwIpWAAAA2V53AACCh71i_SZfT6deBOa2tmDIAAW36HLpAAA=')}, 'URI::https' ),
                                        '_headers' => bless( {
                                                               'user-agent' => 'libwww-perl/6.49',
                                                               'content-type' => 'application/json; charset=utf8',
                                                               '::std_case' => {
                                                                                 'if-ssl-cert-subject' => 'If-SSL-Cert-Subject'
                                                                               },
                                                               'authorization' => 'Bearer <deleted>'
                                                             }, 'HTTP::Headers' ),
                                        '_method' => 'PATCH',
                                        '_uri_canonical' => $VAR1->{'_request'}{'_uri'}
                                      }, 'HTTP::Request' )
               },
1 Answers

I was facing the same issue, but executed a totally different Graph call: My call creates a Microsoft Team and has been successfully working for years... For the last few days, it randomly fails with the same error Jon mentioned.

I made sure that the JSON which is sent as the Payload of the Graph request always gets serialized as UTF-8 encoded string... Even that I cannot be sure that this fixed the issue, I didn't observe errors since then...

Related