Page 1 of 1

Bug in REST API Webhooks

PostPosted: Fri Mar 05, 2021 10:02 pm
by SBarnes
There is a bug inside the code of the api that adds in the header to a webhook in that if the header is to specify a content type you get the error The 'Content-Type' header must be modified using the appropriate property or method.

The fix is to change the one line inside the loop that adds the headers from

Code: Select all
                                             webRequest.Headers[subscriptionRequestHeader.Name] = subscriptionRequestHeader.Value;



to

Code: Select all
                                          if(subscriptionRequestHeader.Name.ToUpper() == "CONTENT-TYPE")
                                          {
                                             webRequest.ContentType = subscriptionRequestHeader.Value;
                                          }
                                          else
                                          {
                                             webRequest.Headers[subscriptionRequestHeader.Name] = subscriptionRequestHeader.Value;
                                          }

Re: Bug in REST API Webhooks  Topic is solved

PostPosted: Sat Mar 06, 2021 12:42 pm
by Mike.Sheen
Thanks!

Logged as DEV-8635

Re: Bug in REST API Webhooks

PostPosted: Tue Mar 09, 2021 11:02 am
by SBarnes
Hi Mike,

You might want to have a look at https://docs.microsoft.com/en-us/dotnet ... mework-4.8 and the remarks section as there are other headers you can't just set via the headers collection.