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 :
Finance | Project Operations, Human Resources, ...
Answered

Error when Serializing Json in AX (Microsoft Dynamics anytype cannot be marshaled to CLR Object)

(0) ShareShare
ReportReport
Posted on by 25

I now have a project that integrates data in and out of AX 2012 using Json Chains.

After following this link:
https://community.dynamics.com/ax/f/microsoft-dynamics-ax-forum/296315/serializing-and-deserializing-json-in-ax


pastedimage1601970881234v1.jpeg

I understand a lot of the concepts but when testing this code in ax job and running it the error below appears


Help, please
Hot Regards.

I have the same question (0)
  • nmaenpaa Profile Picture
    101,172 Moderator on at

    Hi,

    could you share your code, and let us know which line in the code throws this error? This would to narrow down the problem. Thanks!

  • Suggested answer
    Andre Ghazaleh Profile Picture
    870 on at

    Hi Abdelrhman Hiba,

    I think you are getting this error from  this line        

    custObj = CLRInterop::getObjectForAnyType(custContract);

    if so can you check if custContract is Null?

    If CustTable has no rows, custContract will be Null, this might be the cause.

  • AbdelrhmanHiba2020 Profile Picture
    25 on at

    Hi all

    the error in that line :

    custObj = CLRInterop::getObjectForAnyType(custContract);

    and custContract it's not null!

  • Suggested answer
    Andre Ghazaleh Profile Picture
    870 on at

    CLRInterop::getObjectForAnyType Converts a value of the X++ anytype data type to a value of the CLRObject data type.

    You mentioned that you are testing the code in a job, a job executes on client,  X++ CIL is on AOS.

    The reason you are getting this error is because you Execute a job that calls CLRInterop::getObjectForAnyType on client.

  • Verified answer
    WillWU Profile Picture
    22,363 on at

    Hi Abdelrhman Hiba,

    Web services and batch jobs run in CIL, and the CIL generated from X++ exists only on AOS.

    So the CLRInterop::getObjectForAnyType only work in AOS, it will throw the error if you call CLRInterop::getObjectForAnyType directly from the AX client.

  • Suggested answer
    AbdelrhmanHiba2020 Profile Picture
    25 on at

    Hi All

    Thank you all. I solved my problem after following the following link:

    msdax.wordpress.com/.../

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 606 Super User 2026 Season 1

#3
CP04-islander Profile Picture

CP04-islander 356

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans