Skip to content

commerce.media.uploadVideo sends Content-Type: application/json instead of application/octet-stream #215

Description

@dantio

Summary

commerce.media.uploadVideo(videoId, body) posts the raw video binary using the default request Content-Type: application/json. eBay's Media API expects the video to be uploaded as a raw binary stream with Content-Type: application/octet-stream, so uploads sent through this method are likely rejected or mishandled by eBay unless the caller manually overrides the header.

Location

src/api/restful/commerce/media/index.ts

async uploadVideo(videoId: string, body?: any) {
  videoId = encodeURIComponent(videoId);
  return this.post(`/video/${videoId}/upload`, body);
}

The shared REST layer applies defaultApiHeaders with Content-Type: application/json (src/api/restful/index.ts), and uploadVideo does not override it.

Details

  • The OpenAPI spec (specs/commerce_media_v1_beta_oas3.json) does not declare a requestBody/content type for uploadVideo, so this is not caught by the generated types. The requirement (application/octet-stream for the raw .mp4 stream) comes from eBay's Media API documentation and the method's own description ("the input stream for the video source ... an .mp4 file").
  • This is pre-existing behavior (not a regression) — it predates the v10 work. It was surfaced during a bug hunt of the v10 branch.
  • Sibling upload methods that require multipart/form-data (createImageFromFile, uploadDocument, uploadPostOrderDocument) were just fixed to use the existing multipartHeader helper. uploadVideo differs because eBay expects application/octet-stream for video, not multipart — hence a separate issue.

Suggested fix

Set the octet-stream content type on the request, e.g.:

async uploadVideo(videoId: string, body?: any) {
  videoId = encodeURIComponent(videoId);
  return this.post(`/video/${videoId}/upload`, body, {
    headers: {
      'Content-Type': 'application/octet-stream'
    }
  });
}

Optionally add a shared octetStreamHeader constant in src/request.ts (mirroring multipartHeader) if more binary-stream uploads are added later.

Verification suggestion

Add an assertion in the OAS test harness (or a targeted unit test) that uploadVideo issues the request with Content-Type: application/octet-stream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions