I'm using CURL to extract data from a sharepoint list. Now, I'm facing the problem that the data returned from sharepoint is double encoded (e.g. '>' does not become '>' but instead '>'). How can I work around this?
Example call:
POST /sites/00133/_vti_bin/Lists.asmx HTTP/1.1
User-Agent: curl/7.26.0
Host: team.sp.wp.intra.net
Accept: */*
Content-Type: text/xml; charset=utf8
SOAPAction: http://schemas.microsoft.com/sharepoint/soap/GetListItems
<?xml version='1.0' encoding='utf-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:ns4630='http://tempuri.org'>
<SOAP-ENV:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>{D44FAB23-172F-4756-B573-3E903D21F468}</listName>
<viewName>{79D163F7-3750-49DD-9782-AE9F15B35268}</viewName>
<queryOptions><QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions></queryOptions>
<query><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">0023120112</Value></Eq></Where></Query></query>
</GetListItems>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Example resonse:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
SPRequestGuid: 7ec7d0cc-2be3-4884-a54f-bb6883eb3584
X-SharePointHealthScore: 0
X-AspNet-Version: 2.0.50727
Persistent-Auth: true
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 14.0.0.7102
X-MS-InvokeApp: 1; RequireReadOnly
Date: Thu, 30 Jan 2014 12:22:17 GMT
Content-Length: 1967
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="h
ttp://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2 A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'>
<rs:data ItemCount="1">
<z:row ows_LinkTitle='0023120112' ows_Issue_x0020_Name='Test' ows_Description='VPC --> please consider Attachment
' ows__ModerationStatus='0' ows__Level='1' ows_UniqueId='947;#{0FAF4F6D-7952-4771-86C2-81DC3CDB2EAF}' ows_FSObjType='947;#0' ows_Created_x0020_Date='947;#2014-01-07 07:27:04' ows_Modified='2014-01-30 13:10:19' ows_MetaInfo='947;#' ows_ID='947' ows_owshiddenversion='612' ows_Created='2014-01-07 07:27:04' ows_Title='0023120112' ows_FileLeafRef='947;#947_.000' ows_PermMask='0x7fffffffffffffff' ows_FileRef='947;#sites/00133/Lists/Post Go Live Issue Tracking/947_.000' />
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>
</soap:Body>
</soap:Envelope>
Related
I'm trying to download an Excel file from my web page. In the local environment, everything works fine. But in Azure the encoding of the file name gets screwed up. I have already set the globalization tag in web.config as follows:
<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>
Here is how the response is built:
string name = v_NomeArquivo + ".xlsx";
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + name);
Response.BinaryWrite(v_ExcelPackage.GetAsByteArray());
Response.End();
The headers on Azure:
cache-control: private
content-disposition: attachment; filename=Relatório Contrato Limpeza e Higinenização - 2020-10-06_10-55-26.xlsx
content-type: application/ms-excel
date: Tue, 06 Oct 2020 13:55:26 GMT
server: Microsoft-IIS/10.0
status: 200
x-aspnet-version: 4.0.30319
x-powered-by: ASP.NET
And on local:
Cache-Control: private
content-disposition: attachment; filename=Relatório Contrato Limpeza e Higinenização - 2020-10-06_10-58-59.xlsx
Content-Type: application/ms-excel
Date: Tue, 06 Oct 2020 13:58:59 GMT
Server: Microsoft-IIS/10.0
Transfer-Encoding: chunked
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
The only difference is the filename getting messed up and the Transfer-Encoding, could it be it?
You need to use System.Web.HttpUtility.UrlEncode method.
Ex:
string name = System.Web.HttpUtility.UrlEncode(v_NomeArquivo + ".xlsx", System.Text.Encoding.UTF8);
I'm trying to provide the correlation id for this issue but I'm not sure how to obtain it. I assume it should be in response, is that correct? Is it the client-request-id maybe?
HTTP Response
HTTP/1.1 403 Forbidden
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json;odata=minimalmetadata;streaming=true;charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
ocp-aad-diagnostics-server-name: CGa9FFPZASZM+usTGvTzaOZ4zSMxhpbWh2mO9+eJZWs=
request-id: 6ddd7a86-02c9-4dcf-9932-b17afc976107
client-request-id: 50478d75-542d-4e0e-96d9-de913d632471
x-ms-dirapi-data-contract-version: 1.6
ocp-aad-session-key: some-really-long-value
X-Content-Type-Options: nosniff
DataServiceVersion: 3.0;
Strict-Transport-Security: max-age=31536000; includeSubDomains
Access-Control-Allow-Origin: *
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Duration: 782602
X-Powered-By: ASP.NET
Date: Wed, 09 Aug 2017 14:22:21 GMT
Content-Length: 139
{"odata.error":{"code":"Authorization_RequestDenied","message":{"lang":"en","value":"Insufficient privileges to complete the operation."}}}
Token Request Response
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
client-request-id: 8c500700-b75c-403a-a2c9-c6dfa27049d3
x-ms-request-id: 75627b63-fbd6-4fa8-95b5-b6a325d60900
P3P: CP="DSP CUR OTPi IND OTRi ONL FIN"
Set-Cookie: esctx=some-value; domain=.login.microsoftonline.com; path=/; secure; HttpOnly
Set-Cookie: x-ms-gateway-slice=006; path=/; secure; HttpOnly
Set-Cookie: stsservicecookie=ests; path=/; secure; HttpOnly
X-Powered-By: ASP.NET
Date: Wed, 09 Aug 2017 18:33:33 GMT
Content-Length: 1437
{"token_type":"Bearer","expires_in":"3599","ext_expires_in":"262800","expires_on":"1502307214","not_before":"1502303314","resource":"https://graph.windows.net/","access_token":"some-token-value"}
The correlation ID (also called client-request-id) can be found in interactions with the Azure AD service.
The request immediately before this when you were asking the Azure AD endpoints for tokens will include the ID in the response.
https://login.microsoftonline.com/...
https://login.windows.net/...
I have an int-http:outbound-gateway to a rest service with a custom http header but this header is not mapped to the SI message headers although is set on the mapped-response-headers config
here's my config:
<int-http:outbound-gateway
request-channel="inChannel" reply-channel="outChannel"
url-expression="http://localhost:8080/rest" mapped-request-headers="HTTP_REQUEST_HEADERS"
http-method-expression="GET" expected-response-type="java.lang.String"
charset="UTF-8"
mapped-response-headers="HTTP_RESPONSE_HEADERS,mySpecificHeader"/>
Here's the raw response from the rest service:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Expires: Fri, 28 Oct 2016 02:05:34 GMT
mySpecificHeader: headerInfo
Content-Type: application/json
Transfer-Encoding: chunked
Date: Fri, 28 Oct 2016 02:05:34 GMT
{"surname":"Constantine","phone":"+33 555 666 777","name":"John","id":12345}
I have a curl command in linux that works
curl -X POST -H "Authorization: Basic ENCODED_USERNAME_PASSWORD_HERE" -H "Content-Type: application/xml" --data #basicRequest.xml http://abcd/efg/requests/
I tried to write the R equivalent for this and this is what I did so far
getURL("http://abcd/efg/requests/", login = "m12345", password = "123456", httpauth = 1L)
Need help with the rest, no clue how to include the XML file (i have a separate XML file), Content-Type, --data #basicRequest.xml etc...
==================update=======================================
When I run this version of the code
setwd("H:/.../.../TestProject")
xmlfile=xmlParse("test1.xml")
library(httr) ;
t2 = POST(content_type_xml(), authenticate("m12345", "123456", type = "basic"), url='http://abcd/efg/requests/', body=upload_file("test1.xml"),verbose())
I get the following message
-> POST /efg/requests/ HTTP/1.1
-> Authorization: Basic YlRF.....Q==
-> User-Agent: curl/7.39.0 Rcurl/1.95.4.5 httr/0.6.1
-> Host: ....:8786
-> Accept-Encoding: gzip
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/xml
-> Content-Length: 1234
-> Expect: 100-continue
->
<- HTTP/1.1 100 Continue
>> <?xml version="1.0" encoding="UTF-8" ?>
>> <request>
>> <api-id>............</input-file>
>> </request>
<- HTTP/1.1 401 Unauthorized
<- Server: Apache-Coyote/1.1
<- Content-Type: text/html;charset=utf-8
<- Content-Length: 951
<- Date: Tue, 20 Jan 2015 05:28:42 GMT
Dont know where I am wrong ?
I think this a HTTP-related problem.
I want to use my (JAX-RS) RESTeasy Service on a (JEE6) JBoss AS 7 Server from an Android Device. The RESTeasy Service is working fine. I am using on the Client-Side the Restlet-Client. This works too - without Security.
I want to use my JAAS-Formbased Security for the Pattern /rest/* in web.xml. So I have to send a HTTP-POST-Request with the Form-Data (j_username and j_password) to /foo/j_security_check.
I get the JSESSIONID from the first Response by the Server:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=uKUqlkUWdhX2l-FihiWyeSJr.undefined; Path=/foo
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 01:00:00 CET
X-Powered-By: JSF/2.0
Content-Type: text/html;charset=utf-8
Content-Length: 1028
Date: Wed, 15 Aug 2012 11:42:59 GMT
For this anonymous session I am authenticating ...
Header:
POST /foo/j_security_check HTTP/1.1
Date: Wed, 15 Aug 2012 11:42:58 GMT
Accept: text/html
Host: 172.24.47.5:8080
User-Agent: Restlet-Framework/2.0.14
Cookie: JSESSIONID=uKUqlkUWdhX2l-FihiWyeSJr.undefined
Content-Length: 62
Content-Language: *
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content:
j_username=Bob&j_password=a
... and it works: JBoss-Security-TRACE:
2012-08-15 13:22:26,829 TRACE
[org.jboss.security.auth.spi.DatabaseServerLoginModule]
(http-0.0.0.0-0.0.0.0-8080-4) User 'Bob' authenticated, loginOk=true
Now the Problem: In the following request I want to GET the REST-URL (using the Cookie JSESSIONID):
GET /foo/rest/sync/products HTTP/1.1
Date: Wed, 15 Aug 2012 11:42:59 GMT
Accept: application/json
Host: 172.24.47.5:8080
User-Agent: Restlet-Framework/2.0.14
Cookie: JSESSIONID=uKUqlkUWdhX2l-FihiWyeSJr.undefined
Content-Length: 0
But instead of returning the Response with JSON Content, the server is returning the JSF-Login-Page, because it want's me to authenticate again(?):
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 01:00:00 CET
X-Powered-By: JSF/2.0
Content-Type: text/html;charset=utf-8
Content-Length: 936
Date: Wed, 15 Aug 2012 11:42:59 GMT
<?xml version="1.0" encoding="utf-8"?> ... ... ... </html>
If I login with the Browser and then open the REST-URL it works fine. This is the GET-Request by the Browser:
GET http://localhost:8080/foo/rest/sync/products HTTP/1.1
Host: localhost:8080
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko)
Chrome/19.0.1084.56 Safari/536.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=royq26yLd7REOz2otiZdTl6j.undefined
Anyone has an idea? I think the problem lays in the last request (GET /foo/rest/sync/products), because in the Browser it works fine.
Thanks