End of mainstream support for Microsoft Dynamics AX 2009, 2012, and 2012Mainstream support for Dynamics AX 2009 Service Pack 1 (SP1), Dynamics AX 2012, and Dynamics AX 2012 R2 ended Oct. 9, 2018. After that date, only security hotfixes will be provided for these three versions through the extended support period that until Oct. 12, 2021. Read more
Dynamics 365 2019 release wave 2 plan Discover the latest updates to Dynamics 365.Release Plan | Weekly Deployment Notes
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants.Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements.
ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Talent TechTalks
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.
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=trueI believe for a custom service is the same, but I'm not sure.
Can you test and let us know?Regards,Marcel
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.
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.
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.
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
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.
Business Applications communities