Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Managing Data With List

(0) ShareShare
ReportReport
Posted on by 114

Hello everyone, 

I'm trying to get data from a web service. There is a method name is "getCurrencyID" returning data as lista according to the web services document. I get the data with C# but i coudn't compile my code on AX. I had similar issue for another method on same web service. I fixed that problem with this solution link

This is what web services document says;

GetValueListResponse
{
    "Status" : string, // Success , Error
    "StatusMessage" : string,
    "Properties" : List
}

Property
{
    "Key" : string // ID
    "Value" : string // Name
}

This is my C# code;

string _currencyID = client.GetCurrencyId(token, "USD").Properties[0].Key;

I tried to compile it on AX like this;

List currencyIDList = new List(Types::String);


getValueListResponse = axClient.GetCurrencyId(token,"USD");
currencyIDList = getValueListResponse.get_Properties(0).Key;

When i tried to compile it I'm getting this error; "Argument '0' is incompatible with the required type."

How can i solve this? 

  • Emre Karakus Profile Picture
    114 on at
    RE: Managing Data With List

    Yes I agree. I understand what is the meaning of that error

  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    RE: Managing Data With List

    I agree, but that's not related to this code.

    Verify that you're really calling the endpoint and if you do, what needs to be den debugged is the service, not the client.

    I believe that the question of this thread (How to solve compilation error "Argument '0' is incompatible with the required type.") can be considered answered. Do you agree?

  • Emre Karakus Profile Picture
    114 on at
    RE: Managing Data With List

    There is an element in that array when i run that function with C# but there isn't with X++.  I'm missing something but i don't know what is it.

  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    RE: Managing Data With List

    Then you must agree that your previous statement "but still don't know how can i access to that element with X++" doesn't make a good sense. You've just confirmed that that there is no element to access.

  • Emre Karakus Profile Picture
    114 on at
    RE: Managing Data With List

    I already checked that array with your ways when you metioned first time. It is empty. There is no element in it when i try to fill it with X++.

  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    RE: Managing Data With List

    The error in X suggests that the array is empty in that case.

    If you don't how to look at the content, please go and implement one of the two suggestions I gave you. For example, check the Length property. Like this:

    if (properties.get_Lenght() > 0)
    {
    	info("Something found!");
    }
    else
    {
    	throw error("The array is empty!");
    }

    The service provider can't fix the fact that your code isn't prepated for the situation that no elements are returned. It's a bug that you need to fix.

  • Emre Karakus Profile Picture
    114 on at
    RE: Managing Data With List

    Yes I'm agree that. There is such an element but still don't know how can i access to that element with X++. I will try to communicate with service provider. Thank you again for your time.

  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    RE: Managing Data With List

    Yes, it's as I said. You don't get an error when accessing the first element (index = 0) because there is such an element.

    Hopefully you agree that your question "How it's working with C#?" is answered.

  • Emre Karakus Profile Picture
    114 on at
    RE: Managing Data With List

    This is the debugger result with C#. 

    pastedimage1655209372364v1.png

  • Martin Dráb Profile Picture
    231,939 Most Valuable Professional on at
    RE: Managing Data With List

    Now you asked about your C#, which you develop in Visual Studio, won't you? There you don't need to switch anywhere - you're already there.

    Regarding X++, you don't need debugging at the moment. The bug is there and you need to fix it. Please look at the suggestions I gave you.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,274 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,939 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans