Object as parameters for C#API

Asked

Viewed 203 times

1

I have a request made in Angular for C#. However I don’t know how to receive the data in My API In C#.

 getWithFilters(filter: any) {

    let parametros: any = {
        razaoSocial: filter.razaoSocial,
        cnpj: filter.cnpjcpf,
        telefone: filter.telefone
    }

    return this.http
        .get(this.UrlService + '/Clientes', parametros)
        .map((res: any) => res.data)
        .catch((super.serviceError));
}

So I do the request, however in C# How do I receive these parameters?

Thank you in advance. Lucas.

  • 1

    You can create a Viewmodel reflecting your object for the API to serialize/deserialize in C# to receive and respond the object to your client. How is your API?

  • Angelo, I got what I wanted, however I stopped using GET and started sending via POST. As you know in GET we have no way to send a body. Anyway, thanks for your help.

  • 1

    Ahh that was very important, I hadn’t noticed.

  • Yes yes, I ended up forgetting at the time too. Anyway, thank you.

  • 1

    It would be nice if you put your solution as an answer so that this question can help other users in the future.

  • I’ll do that... thanks for the idea.

Show 1 more comment

1 answer

0


I was able to accomplish what I wanted. However I stopped using GET and started sending via POST. Because in GET we have no way to send a body.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.