Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Custom service REST/AP...
Finance forum
Answered

Custom service REST/API / JSON Internal Server Error 500

Posted on by 219
Hello Commuity, hava a 500 internal server error problem on our custom service, using JSON endpoint
 
We don't have any kind of exception throw, our telemetry tells us the /returns/ line of code executed successfully
 
In our DEV enviroment works fine but sometimes on UAT or PROD this service returns 500 Internal Server error
 
These are the main charatherists of our service:
* Total time of processing is about 1 minute or little be more
* No any kind of timeout seems be occuors
* No API limits seems be occurs
* The response is 750000 byes size
* The result contract have nested contracts as lists
* No activity logs on Enviroment Monitor on LCS.
* Works fine on DEV
* Already open a support ticket but no idea founds
 
Our doubts are mainly on dimension (byte) of response and some problems of serializing contract to JSON (too complex or invalid data).
Any exeperience about it?
 
Thanks
Diego
  • Verified answer
    Diego Mancassola Profile Picture
    Diego Mancassola 219 on at
    Custom service REST/API / JSON Internal Server Error 500
    Hello, finnaly found the problem, thanks all for your support.
    The problem at the end was on response header size, in particular ms-dyn-infolog header value, if the value of this header is major than 65k (based on our test) will returned a 500 Internal Server Error.
     
     
    This information is not relevant for us, ans simply clear infolog before returns resolve the problem.
     
    infolog.clear(0);
     
    Thanks Again
    Diego
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 5,451 Super User 2024 Season 2 on at
    Custom service REST/API / JSON Internal Server Error 500
     
    Take a look on this Document maybe it will help you.
     
     
     
     

    Regards,
    Waed Ayyad,
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,071 Super User 2024 Season 2 on at
    Custom service REST/API / JSON Internal Server Error 500
    Hi Diego,

    500 Internal server error, most probably means something went wrong in code. So we need to know what is the message that comes with this 500 error. Do you have try and catch in your custom service? and are u catching errors properly? can u share with us the code so that we can help?

    this code below, should give u more details about the error that happens, then u can return this error in the contract response for your service
            System.Exception ex;
    
            try
            {  
    
            }
            catch(ex)
            {
                error(ex.Message);
            }


    And if you say sometimes it fails in UAT/Prod -- when it fails what happens? do they call the same request again and it works by itself? or what is done exactly?

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Diego Mancassola Profile Picture
    Diego Mancassola 219 on at
    Custom service REST/API / JSON Internal Server Error 500
    Hello Weed, simply FO custom service, a couple of contracts and nothing more.
     
    Our problem is the code works fine, no error, anything can help us whats going error.
     
    Only 500 error returs to client side (in our case Postman)
     
    It's there any limitation on size of response?
    Case we note if the size of the response is major than a "limit" system give us 500 error, but cannot found any specification from Microsoft about this limit on REST/API custom services
  • Waed Ayyad Profile Picture
    Waed Ayyad 5,451 Super User 2024 Season 2 on at
    Custom service REST/API / JSON Internal Server Error 500
     
    Can you give us more details about the API, add some Dummy code related to your code (API)?
     
     
    Regards,
    Waed
  • Diego Mancassola Profile Picture
    Diego Mancassola 219 on at
    Custom service REST/API / JSON Internal Server Error 500
    Hello Waed, thanks for you reply, already do it, but code works fine, it executed fine from the start to the end.
    Seems errors throw after returns on something on serialization or something else.
  • Waed Ayyad Profile Picture
    Waed Ayyad 5,451 Super User 2024 Season 2 on at
    Custom service REST/API / JSON Internal Server Error 500
     
    Try to connect your Dev box with UAT database then call the service and trace the code? 
     
    You can follow this link to connect your UAT database with Dev box:
     
    Regards,
    Waed.
     
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans