Skip to main content

I cannot upload to the Box by calling API in the Azure Data Factory.

I can not use SDK and I got HTTP 400 error ,

“Malformed stream”

following is the Body that I created in the Azure pipeline:( it should be in JSON format)


@concat('--------------------------9fd09388d840fef1

content-disposition: form-data; name=“attributes”


{“name”:“testdev.xlsx”, “parent”:{“id”:“0”}}

--------------------------9fd09388d840fef1

content-disposition: form-data; name=“file”; filename=“testdev.xlsx”

content-type: text/csv


‘, variables(‘varFileContents’),’


--------------------------9fd09388d840fef1–

')

Hi @Shrpmn


Welcome to the forum!


I dont see anything particularly wrong with your request, however creating a upload request by hand is always tricky.


I wonder if Azure doesn’t have a method to make this easier, you might be missing the proper binary upload it self…


As an example, here is a cUrl log from an upload to box:


POST /api/2.0/files/content?fields=id%2Ctype%2Cname HTTP/2
Host: upload.box.com
User-Agent: curl/8.4.0
Accept: */*
Authorization: Bearer 1!k...PVWw.
Content-Length: 423429
Content-Type: multipart/form-data; boundary=------------------------i2ozkLjczzSHhtVvcYCBSQ



--------------------------i2ozkLjczzSHhtVvcYCBSQ
Content-Disposition: form-data; name="attributes"
{. "name": "upload-test.png",. "parent": {. "id": "253757099719". }.}
--------------------------i2ozkLjczzSHhtVvcYCBSQ
Content-Disposition: form-data; name="file"; filename="upload-test.png"
Content-Type: image/png

.PNG
......IHDR..............V......pHYs..........+.....<tEXtComment.
xr:d:DAF1d4MBsqY:26,j:5910270370129294276,t:24031514...w....iTXt
XML:com.adobe.xmp.....<x:xmpmeta xmlns:x='adobe:ns:meta/'>.
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-n xw3.org]

....o..........M`f..}S!0-8..q.e.....s...2........p./.Z..Q;...e.3
M..8u....=.xcJ!..L..B^.03..en..E.=.<....d.1....kO.F...p.........
...Wc.N..9..<...Gh.W.ke .gh.w.ke].....tE.g...o.;.8. .xz....:.H.\.S..}w+^..
.`P.........R.,Y.6y..4G.^#.....,%{.T...H3.s..'.g....V.R8...z&c0;
@.y._.....K...?.cP...4F..-x.E....O..O<..w.k.F..RZ.....VGQ..$4.].

#### Many more lines in binary ###

.........`>..x"..33P.7........~....o.$z~S=.a.A.".<]8
.k.1,N.....f.A./....o.=cp.7.....c..w.<>*....N:$.....
o.......v..,...5..1..'...J]....z.U......w.>p..<....O
}......IEND.B`.
--------------------------i2ozkLjczzSHhtVvcYCBSQ--

Of course the binary is impossible to display as text, hence the dots.


Let us know if this helps.


Reply