web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Set response code to c...
Finance forum

Set response code to custom service

(0) ShareShare
ReportReport
Posted on by 50

I have implemented custom service in D365fO returning response code 200 with body containing status 'failed' or 'succeeded'.

To avoid additional analysis of response's body I'd like to return error specific response code (not 200).

Is that possible to specify any different custom response code for custom service's response?

Categories:
  • Jie G Profile Picture
    Microsoft Employee on at

    Try to see if you can use WebOperationContext.OutgoingResponse.StatusCode in your code.

    docs.microsoft.com/.../system.servicemodel.web.weboperationcontext.outgoingresponse

  • Suggested answer
    Martin Dráb Profile Picture
    241,434 Most Valuable Professional on at

    Yes, it is possible: throw an exception instead of returning a value.

  • Sasha Dudarenko Profile Picture
    50 on at

    Thank you Martin,

    This is a simpliest way, but in this case I will loose respond contract's data. I'd like to keep it.

    How do you think, is that possible to get in to integration framework as mentioned by Ada Ding in previous post?

  • Verified answer
    Martin Dráb Profile Picture
    241,434 Most Valuable Professional on at

    I think you would have to change the implementation of custom services in D365FO kernel, i.e. it's not possible. But note that I've never investigated the possibility of returning custom HTTP codes from D365FO custom services.

    Maybe you could call the custom service through Azure API Management and have a rule there that some other HTTP code should be returned if status is 'failed'.

  • Sasha Dudarenko Profile Picture
    50 on at

    I agree that intrusion in to kernel required, so this is not a dax way because of all MS restrictions.

    I supposed to use Logic App as intermediary, but in this case would be better to propose parsing the response on receiver's side without extra complications.

    Thank you very much for discussion.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans