Base solution for your next web application
Open Closed

How to pass a string as a parameter to a service/api method #11096


User avatar
0
elvis.gene created

If issue related with ABP Framework

  • What is ABP Framework version? 7.1.0

I am working on a Xamarin.Forms project that is comminicating with a .NET api.

To pass an Id to a service method, I use NullableIdDto as a simple integer doesn't work. An example is below

        public async Task<bool> DeleteUserLocationByID(long id)
        {
            var input = new NullableIdDto<long>(id);
            return await _apiClient.DeleteAsync<bool>(GetEndpoint(nameof(DeleteUserLocationByID)), input);
        }

Now, I have a method that needs a string to be passed to an api method. That string is email address. What kind of string object should I pass?

   public async Task<UserLocationShareDto> CreateUserLocationShare(string email)
    {
        return await _apiClient.PostAsync<UserLocationShareDto>(GetEndpoint(nameof(CreateUserLocationShare)), email);
    }

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Elvis,

    To pass an Id to a service method, I use NullableIdDto as a simple integer doesn't work

    Does this work or not ? I couldn't understand, sorry :).

    You can basically create a class as shown below and use it;

    public class EmailAddressDto{
        public string Email {get;set;}
    }