coldfusion - Downloading file though Box API 2.0 giving 200 as response instead of 302 found -


i'm trying download file box.com through api using following code.

<cfhttp url="https://api.box.com/2.0/files/(file_id)/content/" method="get" redirect="true" > <cfhttpparam type="header" name="authorization" value="bearer (developer_token)"> </cfhttp> 

as per documentation should return 302 found response. , redirects dl.boxcloud.com download. i'm getting 200 response.

enter image description here

not sure why i'm getting 200 response. need download file through api call. did missed anything?

with respect @miguel-f's comment, i've surfed , found solution ben nadel's post.

i've got 200 response, because coldfusion followed redirect dl.boxcloud.com (since default, redirect attribute true), , redirected request's response 200.

actually should stop redirect setting redirect attribute false. coldfusion return actual response invoking code.

so i've set redirect attribute false.

<cfhttp url="https://api.box.com/2.0/files/(file_id)/content/" method="get" redirect="false" > <cfhttpparam type="header" name="authorization" value="bearer (developer_token)"> </cfhttp> 

and i'm getting 302 found response per documentation.

enter image description here

with response, we're having location key (in code redirected earlier) in responseheader. using location url can download file using cfheader , cfcontent tags.

reference : https://www.bennadel.com/blog/934-ask-ben-handling-redirects-with-coldfusion-cfhttp.htm


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -