1

I am working on side-project using ASP.Net Core web api. I am currently using Postman so I can interact with custom middleware. As you can see in the picture I have a User id and would like the request header to have more than one value for the user id key. Everytime I debug the api, the request header only counts one value instead of two values. I have looked at the Postman help page but it doesn't really cover any material regarding my issue. So to condense my question, is there a way in Postman that a key (For my scenario, User Id) can hold more than one value.

enter image description here

5
  • 1
    Please post your code for your endpoint. We have no idea what type user id is. Commented Aug 25, 2021 at 4:41
  • No, you can only send String in Header Param, JSON is only a one option to send multiple values but there is no way to send JSON or any thing else apart from string in request header. Commented Aug 25, 2021 at 4:43
  • @RaviS. ok thank you for clearing that up. Commented Aug 25, 2021 at 5:06
  • 1
    @RaviS that makes no sense: "you can't send JSON in a request header, you can only send a string" - what you do you think JSON is? Commented Aug 25, 2021 at 6:13
  • @CaiusJard I already know JSON is also a String type, and JSON is data interchange format. Commented Aug 26, 2021 at 8:12

2 Answers 2

0

Your question doesn't really make sense. Postman will send the data you put, to the server. The data you put is "1,2". At the server end, if you pull the userId value and split it on the comma, you have your two values, no?

I find it incredibly unlikely that when you pull userId at the server, the value of the header is "1" and the other id has disappeared. If the web did that loads of headers (such as your gzip, deflate, br there) would get lost and stuff wouldn't work properly

Sign up to request clarification or add additional context in comments.

Comments

0

In java with spring boot framework i have idea about it we have to send List userIds from request controller method this method you have to take as post method and send that data into body part with

@PostMapping("/listUsers")
public String getList(@RequestBody List<Integer> userIds) {
    // call service method
    return "page";
}


Json Request from postman
{
  1,2,3,4,5............
}

In dot net core

[Produces("application/json")]
[Route("api/accounts")]
public class AccountsController : Controller
{
    [HttpGet]
    [Route("servicesbycategoryids")]
    public IActionResult ServicesByCategoryIds([FromQuery] int[] ids)
    {
        return Ok();
    }
}

4 Comments

this isn't a java related issue, but I now know that header can't send json
I know that this is solution of java, you have to send that data from body not from header in postman. if you want to pass list of data then you have to use POST method
this is the link which are help to you:- stackoverflow.com/questions/51300861/…
NickDotCore I now know that header can't send json - that's absolutely untrue and Ravi should not have misled you thus. Rajesh is doing the same, unfortunately. There is absolutely nothing stopping you putting JSON into an HTTP header, then pulling it out at the server end and deserializing it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.