Blog, Development

Plugin: How to fix “The ‘Accept’ header must be modified using the appropriate property or method. Parameter name: name” error

I was working on the integration between Dataverse and external Rest API. The scenario is simple as – “Send the JSON object to the API when the record is created”. In order to implement this, I decided to develop the plugin that will get the data from the context, transform it to the proper JSON object, and using HttpWebRequest/HttpWebResponse – perform the communication with the external API.

I built the console app in order to test that code works fine before moving the code to the plugin and it looked like the following:

Code worked fine and did what it should with no issues. But when I moved this code to the plugin I immediately got “The ‘Accept’ header must be modified using the appropriate property or method. Parameter name: name” error during the first run. After a few experiments and variations of the code following change fixed the issue:

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.