Skip to content
This repository was archived by the owner on Jan 3, 2026. It is now read-only.
This repository was archived by the owner on Jan 3, 2026. It is now read-only.

[EDIT] Support POSTing binary data to another API using gaxios #348

@arjunk-pki

Description

@arjunk-pki

I'm using gaxios NPM library. I've an external service that accepts application/octet-stream as media type. I need to send a binary data from my Node.JS application to this server. How to do this ?. Whenever I try to send a binary data by converting it to Buffer, that external service throws media type application/json is not supported error. I think, gaxios internally serializes body into application/json. Please see my following code snippet.

const bufferData = Buffer.from(jsonObject.data)

I have to send this binary data using gaxios.

public async postBinaryData(data:Buffer) : Promise<any>{
   const requestOptions: GaxiosOptions = {};
   requestOptions.url = 'http://localhost/api/acceptBinary'; // External Service
   requestOptions.method = 'POST';
   requestOptions.headers['Content-Type'] = 'application/octet-stream'; // Should we add this ? It's not overriding default request mime type.
   const gaxiosResponse = await request(requestOptions);
}

When I used this, I got the below WARN.

Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json' not supported]

Metadata

Metadata

Labels

type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions