BOX File content API range header.

Answered
New post

Comments

2 comments

  • jcleblanc

    Hi there,

    This information should give you more details on how to address the CORS issue, which I'm guessing is related to making the request from JavaScript?

    - Jon

    0
    Comment actions Permalink
  • bhaumik55231

    Hi Jon,

    Yeah, I was trying to make a range request in javascript.

    I figured out after some trial and error that the BOX API was expecting range: bytes={start}-{end} in the request header. But the API reference documentation did not specify that it requires bytes= in the range attribute. Below is the working code, I was not including bytes= earlier and that was causing the issue.

    const response = await fetch(`https://api.box.com/2.0/files/${id}/content`, {
            headers: {
                "Authorization": `Bearer ${access_token}`,
                'range': `bytes=${start}-${end}`
            }, 
        });
     
    Thanks,
    Bhaumik
    0
    Comment actions Permalink

Please sign in to leave a comment.