Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamics CRM Web API POST Products 'Internal Server Error'

(0) ShareShare
ReportReport
Posted on by

Hi,

I've working on a C#.net desktop application to create a products in CRM but when I post my request my response message IsSuccessStatusCode returns false and ReasonPhrase value is "Internal Server Error".

requestUri = https://xxxxxx.xxxxxx.com/api/data/v8.2/products

Content = { "description": "Desc12345", "productnumber": "12345", "name": "Name12345" }

This is for an on-prem. version of CRM and my code to patch/update existing product values all works fine, so I have to assume the Uri isn't the issue.

I've tried including other fields in my content on the assumption that there could be a mandatory value I need to populate but even when I set values to match other products the error still appears.

Can anyone give me suggestions on how I can dig deeper to find details of the error?

Thanks

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    I've just re-checked and I don't (and didn't) have any duplicates, in-fact the CRM database had only a few products in there.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    For me it was enough. Can you please doublecheck that you don't have product with the same productnumber in the system?

  • Community Member Profile Picture
    on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    Goutam/Andrew,

    Thanks for your advise but believe it or not it's now started working.  I've been trying to fix the problem for hours and now it looks like it's posting, typical!.

    Cheers

    Jim

  • Community Member Profile Picture
    on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    I tried adding those fields (as below) after seeing your response to a similar query but it didn't stop the error occurring.

    newProduct.Add("defaultuomscheduleid@odata.bind", "/uomschedules(4560d506-eee2-4cf8-a8d2-3e189ffd5572)");

    newProduct.Add("defaultuomid@odata.bind", "/uoms(bfd3f507-1532-48c1-a35b-d0da82d4f477)");

    newProduct.Add("quantitydecimal", 1);

  • Community Member Profile Picture
    on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    Here's my code:

    string thisRequest = _BaseAddress + _APIDataVersion + "products";

    using (System.Net.Http.HttpRequestMessage thisHttpRequestMessage = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, thisRequest))

    {

       JObject newProduct = new JObject();

       newProduct.Add("description",ProductDescription);

       newProduct.Add("productnumber",ProductNumber);

       newProduct.Add("name",ProductName);

       thisHttpRequestMessage.Content = new System.Net.Http.StringContent(newProduct.ToString());

       thisHttpRequestMessage.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");

       System.Net.Http.HttpResponseMessage thisResponse = httpClient.SendAsync(thisHttpRequestMessage).Result;

       if (thisResponse.IsSuccessStatusCode == false)

       {

           throw new Exception("Error " + thisResponse.ReasonPhrase);

       }

    }

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    Hello Jim,

    You will need to pass defaultuomid, defauluomscheduleid and quantitydecimal fields as well because all of those fields are "platform required".

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Dynamics CRM Web API POST Products 'Internal Server Error'

    Hi Jim ,

    Could you please share your code. Meanwhile you can also validate your code with below reference. The internal server error is basically coming when request is not hitting to the server which you want.

    www.inogic.com/.../programming-using-webapi-through-c-in-dynamics-crm-2016

    You can download fiddler to see where it's actually fails.

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans