In case you're looking for how to convert the file to a byte array for the postman request:

byte[] bytes = System.IO.File.ReadAllBytes(@"C:\temp\myFile.txt");
string bytesStr = string.Join(",", bytes);

This will result into a long string that looks like this:

"49,48,58,50,52,58,50,54,..."

And then use it in the postman request like so:

{
    "FileBytes":[49,48,58,50,52,58,50,54],
    "DeviceId": 12345
}
Answer from Milana on Stack Overflow
🌐
Postman
community.postman.com › help hub
How to send byte array in body - Help Hub - Postman Community
November 17, 2021 - Dear Team, We want to transfer byte array from POSTMAN to an API. We are transferring it into body and it is treating like a string. How we can transfer a byte array from POSTMAN? Your prompt response will be apprecia…
🌐
EzzyBills
ezzybills.com › home › rest api examples using postman
Rest API Examples using Postman - EzzyBills
December 20, 2024 - ... The easiest way to create the data to upload via postman is to use python. You can Install python on your computer then run the following script. The script will read your PDF then generate a raw.txt file (byte array representation of the ...
🌐
Irk
ikio.irk.ru › cp-caldo-3rzzk › send-byte-array-in-json-postman.html
Send byte array in json postman
Instantiate an HMACSHA256 object that is based on the decoded Secret Key byte array (from Step 3). To send an HTTP POST request to bulk-update a channel feed using a JSON object, configure the POSTMAN as shown: In the Headers tab, set the Content-Type as application/json .
🌐
Postman
community.postman.com › help hub
Convert PDF file into Bytes[], pass Bytes[] to request - Help Hub - Postman Community
August 7, 2020 - Hi, I have a PDF file in my local machine. I need to convert PDF into Bytes and pass these Bytes to one of the fields in my JSON request body. Can someone please tell me how can I do this with the postman, please? { "Bytes" :"File Bytes", “Name”: “DamagePackBlobName”, “Size” :“fileBytes.Length”, “PackName” : “Constants.DamagePack”, “FileType” : “fileType” }
🌐
Postman
community.postman.com › help hub
Pass byte array from csv file to post method - Help Hub - Postman Community
October 4, 2024 - Hello, I’m having some issue passing the bytes from a csv file to my api method. I pass in a ClientId and a Token via the parameters: In the body of the request, how do you pass the bytes of the file?
🌐
Google Groups
groups.google.com › g › restsharp › c › LmdZ0sf4HrE
posting a byte array
The object has a number of properties, but the Json serializer seems to choke on the one byte[] property of the object (it throws an exception saying that it can't convert it to a string). As a workaround, I'm UTF8 encoding the byte array, making the property a string, and posting it that way.
🌐
Postman
community.postman.com › help hub
How to send a POST request with binary data as request body? - Help Hub - Postman Community
October 4, 2023 - Hi, I can send a POST request using binary data as a response body successfully using the normal POST request but I wanted to replicate the same behavior using the pre-request script. The only thing I am struggling with is the creation of the request body. For example, let’s say I have a ...
Find elsewhere
🌐
Mediocampidanosostenibile
mediocampidanosostenibile.it › how-to-send-byte-array-in-json-postman.html
how-to-send-byte-array-in-json-postman - Google Search
Click this link to download a sample byte array representation of a test PDF invoice. Click Send in the end. In the response window below, you will see a ... ... You will see more English now. ... In the Postman, click the Body tab and select the option raw and then choose the JSON format., ...
🌐
Postman
blog.postman.com › home › sending and debugging binary data in postman requests
Sending and Debugging Binary Data in Postman Requests | Postman Blog
December 16, 2025 - While modern APIs predominantly use text-based formats like JSON to exchange data, there are times when binary data needs to be sent, such as uploading an image or a file. Let’s look at the intricacies of sending binary data in a POST request using Postman, how to set the correct headers, and debugging with the Postman Console.
🌐
Postman
community.postman.com › help hub
How to pass an array to the body as json in postman - Help Hub - Postman Community
January 20, 2021 - Hello Everyone, I want to know how to pass an array to the response body? I am saving an array as an environmental variable as a string, but I want to pass that array to the response body as an array not as string. Please anyone help me with this. This is how I save the variable const recordsArr = JSON.parse(responseBody).records; pm.environment.set(“recordsArr”, JSON.stringify(recordsArr)); And I want to pass like this.
🌐
MuleSoft
help.mulesoft.com › s › question › 0D52T00004mXVR0SAO › i-am-hitting-an-json-via-postman-and-in-flow-i-have-an-http-connector-now-i-need-to-get-that-json-r
i am hitting an JSON via postman and in flow i have ...
July 23, 2020 - MuleSoft Help Center provides MuleSoft Forums, resources, training, discussion groups, support and details about the MuleSoft Community.
🌐
CodingTechRoom
codingtechroom.com › question › send-byte-array-json-post-request
How to Send a Byte Array in a JSON POST Request? - CodingTechRoom
const byteArray = new Uint8Array([5, ... When sending a byte array in a JSON POST request, you need to encode the byte array into a format that can be included in JSON....
🌐
Postman
community.postman.com › help hub
How to send byte array in body - #2 by pranavdavar - Help Hub - Postman Community
November 17, 2021 - Hi @lavishsahu, Can you please try to send base64 encoded string of your byte array in body of postman. And keep the content type as requested by your target application. Hope this helps 😊
Top answer
1 of 2
6

Firstly, asp.net core does not support post multiple parameters from body, you need put these parameters into a model then you could post them from body.

Then, what you did should be post from query. But it seems does not support byte[] from query.

  1. If you use JSON.NET, you could post clientId,dtName and append from query and post dtValues from body like below(Be sure your controller is declared with [ApiController]):

  1. If you use System.Text.Json,with Sytem.Text.Json a byte array (byte[]) will be serialized as base64 string. They stated that they won't add support for byte[] to be serialized as number array in a github issue.

Custom JsonConverter:

public class ByteArrayConverter : JsonConverter<byte[]>
{
    public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        short[] sByteArray = JsonSerializer.Deserialize<short[]>(ref reader);
        byte[] value = new byte[sByteArray.Length];
        for (int i = 0; i < sByteArray.Length; i++)
        {
            value[i] = (byte)sByteArray[i];
        }

        return value;
    }

    public override void Write(Utf8JsonWriter writer, byte[] value, JsonSerializerOptions options)
    {
        writer.WriteStartArray();

        foreach (var val in value)
        {
            writer.WriteNumberValue(val);
        }

        writer.WriteEndArray();
    }
}

Register it:

services.AddControllers().AddJsonOptions(options =>
{
     options.JsonSerializerOptions.Converters.Add(new ByteArrayConverter());
}); 

Test in Postman:

BTW, not sure what is your scenario, if you post the byte array is something like file(e.g: image or .doc or .xlx file), you could use IFormFile and add [FromForm] before the parameter. Both JSON.NET or System.Text.Json supports receive IFormFile, no need custom JsonConverter here:

[Route("Upload")]
public IActionResult Upload(int clientId, string dtName, [FromForm]IFormFile dtValues, bool append)
{
        return Ok();
}

Post the data like below:

If you do not want to separately post them from query and body, you could put them into a model and post them from body.

Model:

public class TestModel
{
    public int clientId { get; set; }
    public string dtName { get; set; }
    public byte[] dtValues { get; set; }
    public bool append { get; set; }
}

Post in Postman:

Note: if you use System.Text.Json, you still need to custom JsonConverter like above option 2 I shared.

2 of 2
1

You have to pass array and not string.

dtValues : [37,80]
🌐
Mastropanegreco
mastropanegreco.it › how-to-send-byte-array-in-json-postman.html
We cannot provide a description for this page right now