0

i have access to our sharepont via webservices , using OAth2 i retrieve the token first , then using the token i will retreve the data of a csv file. but while retrieving the data of the csv file am getting whole of a csv content in a single xml element in the response. below is the xml response of the get webservice

<rest-adapter-response>
  <metadata>
    <status>success</status>
  </metadata>
  <status-line>
    <code>200</code>
    <reason>OK</reason>
  </status-line>
  <header-lines>
    <Cache-Control>private, max-age=0</Cache-Control>
    <Transfer-Encoding>chunked</Transfer-Encoding>
    <Content-Type>application/octet-stream</Content-Type>
    <Expires>Tue, 23 Apr 2019 18:14:47 GMT</Expires>
    <Last-Modified>Wed, 08 May 2019 18:14:47 GMT</Last-Modified>
    <Server>Microsoft-IIS/10.0</Server>
    <X-SharePointHealthScore>5</X-SharePointHealthScore>
    <X-SP-SERVERSTATE>ReadOnly=0</X-SP-SERVERSTATE>
    <DATASERVICEVERSION>3.0</DATASERVICEVERSION>
    <X-Download-Options>noopen</X-Download-Options>
    <Content-Disposition>attachment</Content-Disposition>
    <SPClientServiceRequestDuration>139</SPClientServiceRequestDuration>
    <X-AspNet-Version>4.0.30319</X-AspNet-Version>
    <SPRequestGuid>48adda9e-0094-8000-86e1-83db58a69267</SPRequestGuid>
    <request-id>48adda9e-0094-8000-86e1-83db58a69267</request-id>
    <MS-CV>ntqtSJQAAICG4YPbWKaSZw.0</MS-CV>
    <Strict-Transport-Security>max-age=31536000</Strict-Transport-Security>
    <X-FRAME-OPTIONS>SAMEORIGIN</X-FRAME-OPTIONS>
    <X-Powered-By>ASP.NET</X-Powered-By>
    <MicrosoftSharePointTeamServices>16.0.0.8824</MicrosoftSharePointTeamServices>
    <X-Content-Type-Options>nosniff</X-Content-Type-Options>
    <X-MS-InvokeApp>1; RequireReadOnly</X-MS-InvokeApp>
    <P3P>CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"</P3P>
    <Date>Wed, 08 May 2019 18:14:47 GMT</Date>
  </header-lines>
  <message-body>
    <non-xml-data-response>COA,COA Acct Desc,Acct Prefix,Revaluation Acct,Mapping Changes - Additions( A )  Deletions ( D ) Changes ( C ),MJE,OIM Recon,Comments for difference:10000274,"Citibank, Operating, USD, 31165975",1000,10009999,A,,X,10000374,"Citibank, Clearing, USD, 31165975",1000,10009999,A,,X,10006604,"HSBC, Operating, SAR, SA0345000000003179660002",1000,10009999,A,,X,10006605,"Citibank, Operating, ZAR, 0202099009",1000,10009999,A,,X,123,,,456,,,,</non-xml-data-response>
  </message-body>
</rest-adapter-response>

if you can the whole of csv content is coming under ,also the csv content looses its format , ie the new line for every line is missing. can some one guide how to preserve the format ? below are the possible solutions i consider .

  1. we may use excel instead of csv , but when i retrieve the excel data am getting un recognised characters. so we should over come that hurdle

2.downloading the csv file instead of reading its content . so that after downloading i wil lread the read the csv file seperately. but for that i need to again construct proper restwebservice url. am not sure how to do it.

now lets come to the webservice link and function i used to retrieve the csv data

https://collaboration.xxx.com/sites/amseimcts/_api/web/getfilebyserverrelativeurl('/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/$value?binaryStringResponseBody=true

the tool in which am using the above url has a bultin work flow which will take the rest url as input and give the rest response as output in the format which we saw above in xml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.