Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

CallContext for Custom Service using JSON Endpoint in AX 7

(0) ShareShare
ReportReport
Posted on by 3

Hello,

Is it possible to specify a "CallContext" when calling a custom service at the JSON endpoint in the new Dynamics AX? I'd like to be able to specify the company.

I've tried specifying a "Company" request header and a "CallContext" request header but get a 500 response in both cases.

Thanks in advance.

*This post is locked for comments

  • Verified answer
    Mea_ Profile Picture
    60,278 on at
    RE: CallContext for Custom Service using JSON Endpoint in AX 7

    Hi mjjoachim,

    Yep I probably missed part about JSON and thought that you are talking about OData.

    However, I have not heard about call context with JSON as well, here is a similar question on yammer

    www.yammer.com/dynamicsaxfeedbackprograms

    I don't know if you have access to it or not but solution that is proposed there is to pass company inside of JSON request and  do changecompany in your service manually.  

  • mjjoachim Profile Picture
    3 on at
    RE: CallContext for Custom Service using JSON Endpoint in AX 7

    Hi ievgen,

    It may be that there is no way to switch the company via the JSON endpoint for custom services. However, it is possible to pass a CallContext object for the same custom service via the SOAP endpoint. So it seems like it would be a pretty big oversight to omit it for the JSON endpoint.

    Just to be clear, I'm calling a Dynamics AX custom service, not the OData service.

    If I can't figure this out, I will resort to using the SOAP endpoint or manually switching the company within the service. But I don't think that is a good idea if there is a more standard way to do it.

    Thanks

  • Mea_ Profile Picture
    60,278 on at
    RE: CallContext for Custom Service using JSON Endpoint in AX 7

    Hi mjjoachim,

    As far as I know there is no "company" context and it will return you data from user's default company. The only work around I have heared is to use "cross-company=true" query option and than filter by company in your application.

  • mjjoachim Profile Picture
    3 on at
    RE: CallContext for Custom Service using JSON Endpoint in AX 7

    Thank you Marcel, I had not tried that.

    Unfortunately, it does not seem to work. I am using the following service address: usnconeboxax1aos.cloud.onebox.dynamics.com/.../Services[ServiceGroup]/[Service]/insert?$filter=dataAreaId eq 'USP2'&cross-company=true. If the user's default company is USP2 the call works. If the user's default company is not USP2, the call fails because of a referential integrity violation. So I think the call is OK, but using the OData syntax does not seem to be changing the company.

    Thank you though.

  • Suggested answer
    Marcel Ferreira Profile Picture
    on at
    RE: CallContext for Custom Service using JSON Endpoint in AX 7

    Hi mjjoachim,

    If you're working with oData, to select an specific company you have to use something like this:
    http://[baseURI]/data/FleetCustomers?$filter=dataAreaId eq ‘usrt’&cross-company=true

    I believe for a custom service is the same, but I'm not sure.

    https://ax.help.dynamics.com/en/wiki/dynamics-ax-7-services-technical-concepts-guide/


    Can you test and let us know?

    Regards,
    Marcel

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 AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans