How do I pass array from Angular 6 to ASP.NET Core API for GET method?

Staytrippy

So what I'm expecting is when Angular 6 app request with GET Method, sending a list or array of unique identifier as a parameter to the ASP.NET Core web API, then ASP.NET Core will bring information only relevant to the array of unique identifier back to the angular app.

My web API code looks something like this.

[HttpGet]
public ActionResult GetByGuids(List<Guid> Guids)
{
  // some code here...

  return Ok(_someService.someAction(Guids)); 
  //Guids will be passed as a parameter to the function of service layer
}

According to my own research, I cannot add the array of unique identifier to the body because this is GET method.

I have to add [FromQuery] since it produces an error if I don't add it when a parameter is array or list.

If [FromQuery] is the only way to deal with this situation, then I have no idea how I should write the code for Angular.

Please help.

Thank you in advance.

John

Change List<Guid> Guids to [FromQuery]List<Guid> Guids:

public ActionResult GetByGuids([FromQuery]List<Guid> Guids)

You can then make the request as http://myserver/controller/GetByGuids?Guids=6d627994-dce5-487e-bd2c-d48c0311a2e0&Guids=29a76d51-3c44-4fde-a0f1-b1f34567175e

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to pass int array (int[]) to a Get method in ASP.NET Core

From Dev

How do I delete multiple rows with it's Id matching an Id from the http get array I sent to the method? (.NET Core)

From Dev

How do I do file upload using ASP.NET Core 6 minimal api?

From Dev

Sending class objet to asp.net core web api http get method from angular 12

From Dev

How to pass array of datetime from vue.js to an ASP.NET Core API?

From Dev

How to pass an array as a body from jQuery POST method to ASP.NET Web API?

From Dev

how to pass parameters to asp.net web api get method?

From Dev

How do I send an email from angular to the endpoint using angular 5 and asp.net core

From Dev

How do I get a dependency needed in one method only, using ASP.NET Core

From Dev

How do I instantiate a service from another controller in a controller in ASP.NET Core 6 MVC EF?

From Dev

How to pass multiple parameters from angular 8 to .NET Core API

From Dev

How to get data from local Web API (ASP.NET Core) in Angular

From Dev

How can I pass model to an access data layer/EF Core project from a separate ASP.NET Core Web API project

From Dev

How can I hit Asp.net Core Api from Angular 2

From Dev

How do I call my API controller object from an ASP.NET Core page?

From Dev

How do I get the connection string from the SqlServerDBContextOptionsExtensions in ASP.Net Core

From Dev

How do I get the user id from my database and display it using ASP.NET Core MVC

From Dev

How do I pass <summary> from ASP.net webservice?

From

How do I get current user in .NET Core Web API (from JWT Token)

From Dev

How do I get blobs metadata on ASP.NET Core 2.1? FetchAttributes method looks like being not implemented

From Dev

How to get images in Angular from an ASP.NET Web API?

From Dev

How to pass list of class object in get method - asp.net core 2.1

From Dev

Pass the result of Asp.net Core API to Angular

From Dev

How do I pass data from an ASP.NET WebAPI ApiController to an ASP.NET MVC Controller?

From Dev

Unable to fetch data from asp.net core api into angular 6

From Dev

How to pass Model property from ActionLink to Post method (with asp.net core)?

From Dev

How to pass data and image both to "ASP.NET Core" Web API using Angular 2(typescript)?

From Java

How pass json array in Angular post method and how get this array in Api?

From Dev

Download file using Angular 6 from an ASP.NET Web API method

Related Related

  1. 1

    How to pass int array (int[]) to a Get method in ASP.NET Core

  2. 2

    How do I delete multiple rows with it's Id matching an Id from the http get array I sent to the method? (.NET Core)

  3. 3

    How do I do file upload using ASP.NET Core 6 minimal api?

  4. 4

    Sending class objet to asp.net core web api http get method from angular 12

  5. 5

    How to pass array of datetime from vue.js to an ASP.NET Core API?

  6. 6

    How to pass an array as a body from jQuery POST method to ASP.NET Web API?

  7. 7

    how to pass parameters to asp.net web api get method?

  8. 8

    How do I send an email from angular to the endpoint using angular 5 and asp.net core

  9. 9

    How do I get a dependency needed in one method only, using ASP.NET Core

  10. 10

    How do I instantiate a service from another controller in a controller in ASP.NET Core 6 MVC EF?

  11. 11

    How to pass multiple parameters from angular 8 to .NET Core API

  12. 12

    How to get data from local Web API (ASP.NET Core) in Angular

  13. 13

    How can I pass model to an access data layer/EF Core project from a separate ASP.NET Core Web API project

  14. 14

    How can I hit Asp.net Core Api from Angular 2

  15. 15

    How do I call my API controller object from an ASP.NET Core page?

  16. 16

    How do I get the connection string from the SqlServerDBContextOptionsExtensions in ASP.Net Core

  17. 17

    How do I get the user id from my database and display it using ASP.NET Core MVC

  18. 18

    How do I pass <summary> from ASP.net webservice?

  19. 19

    How do I get current user in .NET Core Web API (from JWT Token)

  20. 20

    How do I get blobs metadata on ASP.NET Core 2.1? FetchAttributes method looks like being not implemented

  21. 21

    How to get images in Angular from an ASP.NET Web API?

  22. 22

    How to pass list of class object in get method - asp.net core 2.1

  23. 23

    Pass the result of Asp.net Core API to Angular

  24. 24

    How do I pass data from an ASP.NET WebAPI ApiController to an ASP.NET MVC Controller?

  25. 25

    Unable to fetch data from asp.net core api into angular 6

  26. 26

    How to pass Model property from ActionLink to Post method (with asp.net core)?

  27. 27

    How to pass data and image both to "ASP.NET Core" Web API using Angular 2(typescript)?

  28. 28

    How pass json array in Angular post method and how get this array in Api?

  29. 29

    Download file using Angular 6 from an ASP.NET Web API method

HotTag

Archive