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 - ... {“PictureName”:”taxinvoice.pdf”,”PictureStream”:[37,80,68,70,45,49,46,55,13,10,37,181,181,181,181,13]} Replace the green number in the bracket with a byte array representation of the image you are uploading.
🌐
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
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?
🌐
Postman
community.postman.com › help hub
Convert PDF file into Bytes[], pass Bytes[] to request - Help Hub - Postman Community
August 7, 2020 - 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” ...
🌐
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.
🌐
Mediocampidanosostenibile
mediocampidanosostenibile.it › how-to-send-byte-array-in-json-postman.html
how-to-send-byte-array-in-json-postman - Google Search
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., Once we send some the request body via POST method, the API in ...
Find elsewhere
🌐
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 - Setting headers: You will need to set the Content-Type header when sending binary data, and should match the data type you are transmitting. For example, if you are sending a JPEG image, your Content-Type header should be set to image/jpeg. Postman will attempt to set this header for you, but double-check that it is set correctly.
🌐
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.
🌐
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 ...
🌐
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 😊
🌐
CodingTechRoom
codingtechroom.com › question › send-byte-array-json-post-request
How to Send a Byte Array in a JSON POST Request? - CodingTechRoom
Use Base64 encoding to transform the byte array into a string that can be included in the JSON. Alternatively, you may use binary formats like ArrayBuffer or Blob, depending on your environment.
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