Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

For GET you can refer to the following SO question:

Pass an array of integers to ASP.NET Web API?Pass an array of integers to ASP.NET Web API?

If you want to try to use POST then continue to read:

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept accept POST and your new AddRoleModel DTO instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}

For GET you can refer to the following SO question:

Pass an array of integers to ASP.NET Web API?

If you want to try to use POST then continue to read:

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept accept POST and your new AddRoleModel DTO instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}

For GET you can refer to the following SO question:

Pass an array of integers to ASP.NET Web API?

If you want to try to use POST then continue to read:

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept accept POST and your new AddRoleModel DTO instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}
Added link to answered SO question for GET
Source Link
BlakeH
  • 3.5k
  • 2
  • 26
  • 32

For GET you can refer to the following SO question:

Pass an array of integers to ASP.NET Web API?

If you want to try to use POST then continue to read:

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept thataccept POST and your new AddRoleModel DTO instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept that instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}

For GET you can refer to the following SO question:

Pass an array of integers to ASP.NET Web API?

If you want to try to use POST then continue to read:

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept accept POST and your new AddRoleModel DTO instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}
Source Link
BlakeH
  • 3.5k
  • 2
  • 26
  • 32

You should create a DTO for your parameters like such:

public class AddRoleModel
{
    Guid UserId { get; set; }
    Guid[] RoleIds { get; set; }
}

Change your method to accept that instead of the two different parameters like so:

[HttpPost]
public void AddRoles(AddRoleModel model)
{
   ...
}

And POST the json for that model to the method

json could look like this:

{    
    UserId: "{guid}",
    RoleIds: ["{some guid}", "{some other guid}"]
}