on 12-17-2014 4:22 PM
Hi All,
I´m on BO 4.1 SP5 trying to export an excel sheet, using javascript, to the repository.
I´m getting an HTTP 500 error.
Following is my code
bodie = '--10f3211b-66e8-4b14-93ec-b11ec5c19a43-41d3c84c-d157-4377-aba9-41353b9a4dfe \
Content-Disposition: form-data; name="attachmentInfos"\
Content-Type: application/xml\
<spreadsheet>\
<name>//lambari/pmae-d/corporativo/usuarios.xls</name>\
<folderId>234707</folderId>\
</spreadsheet>\
--10f3211b-66e8-4b14-93ec-b11ec5c19a43-41d3c84c-d157-4377-aba9-41353b9a4dfe\
Content-Disposition: form-data; name="attachmentContent"\
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\
... Excel 2007 document as a binary stream...\
--10f3211b-66e8-4b14-93ec-b11ec5c19a43-41d3c84c-d157-4377-aba9-41353b9a4dfe--'
// ==================================================================================================
var docum = new XMLHttpRequest();
// url da consulta
var url = 'http://vrt0568.bndes.net:6405/biprws/raylight/v1/spreadsheets';
docum.open('POST', url, false);
docum.setRequestHeader('X-PINGARUNER', 'pingpong');
docum.setRequestHeader('Content-Type', 'multipart/form-data');
docum.setRequestHeader('Accept', 'application/xml');
docum.setRequestHeader('X-SAP-LogonToken', tokenDec);
docum.send(bodie);
Am I using the right url ?
Cheers,
Rogerio
Hi Rogerio,
your URL looks fine. I think the issue is with the Body where you have text in-line with the binary content of the file.
To get it working for myself, I broke the body into 3 parts, the header, the file stream and the footer.
I converted the header and footer into byte arrays and then concatenated the 3 parts together as my request stream.
the below is C# code, but hopefully it demonstrates what I'm talking about:
//write the request body to the stream
byte[] reqBodyStart = System.Text.Encoding.UTF8.GetBytes(bodyStart);
byte[] reqBodyEnd = System.Text.Encoding.UTF8.GetBytes(bodyEnd);
Stream reqStream = myWebRequest.GetRequestStream();
reqStream.Write(reqBodyStart, 0, reqBodyStart.Length);
//add file to stream
reqStream.Write(filestream, 0, filestream.Length);
reqStream.Write(reqBodyEnd, 0, reqBodyEnd.Length);
reqStream.Close();
Dan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anthony,
I´ve just seen your reply today..
In fact I´really don´t test the approach.
What I was intending to do is to alter the the personal DP from a WEBI Document so I was thinking in schedule the report to the file system, upload the excel and then modify the DP for a report.
But I think it´s a very demandinfg task because of the size of the Excel file.
So I think about schedulin the report to BO´s server , get the ID of this scheduled report and then change the DP.
But I didnt try this approach yet.
I´m considfering wrtie a document about uing the RESTFUL API with Javascript next year.
Merry Christas,
Rogerio
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.