Issue with uploading files with RCURL - r

Here, I want to attach a file to certain Policy/Claim Number with the below command in the intranet URL.
library(RCurl)
options(RCurlOptions = list(
cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"),
followlocation = TRUE,
httpheader = c(
Accept = "text/xml",
Accept = "multipart/*",'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "INTRANET URL"
),
userpwd = "USERID:PASSWORD",
netrc = TRUE,
timeout = 100,
postfields = CONTAINS SOAP DATA,
writefunction = reader$update,
verbose = TRUE,
httpauth = AUTH_BASIC)
)
getForm(
uri = "INTRANET URL",
file = fileUpload(
filename = "C:\\Users\\Username\\Desktop\\image001.pdf",
contentType = "application/pdf"
),
upload = TRUE
)
When I run the above commands, I am getting the status as "HTTP/1.1 200 OK" but the response from the service says no attachment.
* Couldn't find host applications.test.intra.XXXXX.nl in the _netrc file; using defaults
* Trying 11.11.11.11... * Connected to URL (11.11.11.11) port 443 (#0)
* successfully set certificate verify locations:* CAfile: C:/Program Files/R/R-3.4.2/library/RCurl/CurlSSL/cacert.pem
CApath: none* SSL connection using TLSv1.0 / ROOT* Server certificate:
* subject: CN=applications-tst.XX.XXXXX.com* start date: DATE TIMESTAMP GMT
* expire date: DATE TIMESTAMP GMT* subjectAltName: applications.test.intra.XXXXX.XX matched
* issuer: DC=com; DC=XXXXX; DC=us; CN=XXXXX-SHA2-Issuing-us-XXXXXXXXXX-CA* SSL certificate verify ok.
* Server auth using Basic with user 'USERID'
> POST /QUALIFIER1/QUALIFIER2/QUALIFIER3?file=C%3A%5CUsers%5CUSERNAME%5CDesktop%5Cimage001.pdf&file=character%280%29&file=application%2Fpdf&upload=TRUE HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX= Host: applications.test.intra.XXXXX.nl
Accept: text/xml Accept: multipart/* Content-Type: text/xml; charset=utf-8
SOAPAction: https://applications.test.intra.XXXXX.nl/QUALIFIER1/QUALIFIER2/QUALIFIER3 Content-Length: 2654 Expect: 100-continue
* Done waiting for 100-continue < HTTP/1.1 200 OK < content-language: en-GB
< content-type: text/xml; charset=utf-8 < date: Fri, 24 Nov 2017 11:33:00 GMT < p3p: CP="XXX XXX XXX XXX XXX XXX"
< transfer-encoding: chunked < cache-control: no-cache="set-cookie, set-cookie2" < expires: Thu, 01 Dec 1994 16:00:00 GMT
< x-powered-by: Servlet/3.0 < Set-Cookie: LtpaToken2=TOKEN; Path=/; Secure; HttpOnly
< Set-Cookie: BIGipServer~XX~isam-emp-applications_tst_11111=111111111.11111.1111; path=/; Httponly; Secure
< * Connection #0 to host applications.test.intra.XXXXX.nl left intact

Related

Why curl returns different response from telnet from a web server

Hello I did run curl command and equal telnet command but response is different.
I try to get HTTP HEADER response code from a web server.
curl returns correct response, page indeed doesn't exist. But telnet with equal request return different response.
Please see CURL code:
$ curl -vI "https://www.abcanchorage.org/not-exist-page-con2uiu28itact"
* About to connect() to www.abcanchorage.org port 443 (#0)
* Trying 185.230.63.96...
* Connected to www.abcanchorage.org (185.230.63.96) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* subject: CN=abcanchorage.org
* start date: Nov 09 17:32:52 2020 GMT
* expire date: Feb 07 17:32:52 2021 GMT
* common name: abcanchorage.org
* issuer: CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US
> HEAD /not-exist-page-con2uiu28itact HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.abcanchorage.org
> Accept: */*
>
< HTTP/1.1 404 Not Found
HTTP/1.1 404 Not Found
< Date: Mon, 14 Dec 2020 14:06:25 GMT
Date: Mon, 14 Dec 2020 14:06:25 GMT
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Connection: keep-alive
Connection: keep-alive
< content-language: en
content-language: en
< x-wix-request-id: 1607954785.82658627446080423994
x-wix-request-id: 1607954785.82658627446080423994
< Age: 0
Age: 0
< Server-Timing: cache;desc=miss, varnish;desc=miss, dc;desc=84
Server-Timing: cache;desc=miss, varnish;desc=miss, dc;desc=84
< X-Seen-By: r5KTLwzxoi1C+SXup0UeuQ==,sHU62EDOGnH2FBkJkG/Wx8EeXWsWdHrhlvbxtlynkVg1leqePNkwQ1H/U0dj1nMN,2d58ifebGbosy5xc+FRalthBvkD9LHf+OIny1MrcDwiq6+5o8xu+S2UUMqtKcebjUMQY1HiUPm50af1ZAsGkCw==,2UNV7KOq4oGjA5+PKsX47Gzh5saLoQp8TIRIohc0Wac=,m0j2EEknGIVUW/liY8BLLuvhI/meCohDY7RevwAJ7JU=,w4q8mm9FnmU4emOs6psVXTk8VV0IpMOWw3zRTVWAPzKTzRA6xkSHdTdM1EufzDIPWIHlCalF7YnfvOr2cMPpyw==,8OhaUUQpIrZVCQED4XmuQ40tjCf+ijnQjDvVBuKrqCUYXyC7l2oN0jRBomMsk5tniLmOBCJX9PwPq0FFNfh5cw==
X-Seen-By: r5KTLwzxoi1C+SXup0UeuQ==,sHU62EDOGnH2FBkJkG/Wx8EeXWsWdHrhlvbxtlynkVg1leqePNkwQ1H/U0dj1nMN,2d58ifebGbosy5xc+FRalthBvkD9LHf+OIny1MrcDwiq6+5o8xu+S2UUMqtKcebjUMQY1HiUPm50af1ZAsGkCw==,2UNV7KOq4oGjA5+PKsX47Gzh5saLoQp8TIRIohc0Wac=,m0j2EEknGIVUW/liY8BLLuvhI/meCohDY7RevwAJ7JU=,w4q8mm9FnmU4emOs6psVXTk8VV0IpMOWw3zRTVWAPzKTzRA6xkSHdTdM1EufzDIPWIHlCalF7YnfvOr2cMPpyw==,8OhaUUQpIrZVCQED4XmuQ40tjCf+ijnQjDvVBuKrqCUYXyC7l2oN0jRBomMsk5tniLmOBCJX9PwPq0FFNfh5cw==
< Cache-Control: no-cache
Cache-Control: no-cache
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
<
* Connection #0 to host www.abcanchorage.org left intact
Please see TELNET code:
$ telnet www.abcanchorage.org 80
Trying 35.246.6.109...
Connected to www.abcanchorage.org.
Escape character is '^]'.
HEAD /not-exist-page-con2uiu28itact HTTP/1.1
User-Agent: curl/7.29.0
Host: www.abcanchorage.org
Accept: */*
HTTP/1.1 301 Moved Permanently
Date: Mon, 14 Dec 2020 14:08:50 GMT
Content-Length: 0
Connection: keep-alive
location: https://www.abcanchorage.org/not-exist-page-con2uiu28itact
Age: 1496
Server-Timing: cache;desc=hit, varnish;desc=hit, dc;desc=euw2
X-Seen-By: sHU62EDOGnH2FBkJkG/Wx8EeXWsWdHrhlvbxtlynkVgmNySqidgeEPHXBvm3U9iS,2d58ifebGbosy5xc+FRalhEF/w8i5SZb0AgDKvjhMuBVlHGeDiRYk3btR6xZR3zaGgqFbFMYwiXnFojPwdof6LPb61OjwxlOgfM3AWuO4IQ=,2UNV7KOq4oGjA5+PKsX47LZ7Kls+1whC/C/a0aUIqJE=
Cache-Control: no-cache
Expires: -1
X-Wix-Request-Id: 1607954930.2811039255969122439
Server: Pepyaka/1.19.0
^]quit
telnet> quit
Connection closed.

Getting Internal Server Error when using RCurl with API's in R

I am relatively new to API's and all that stuff, but I try to collect data through an API for http://my.wirelesstag.net through R with the RCurl package. Yesterday it worked just fine, but today I get an following error: Error: Internal Server Error. I suspect that the error occurs because I don't close the previous connection—maybe I am wrong. Anyway, any help to get the script working is appreciated.
My script for retrieving the data is as below (the example is unfortunately not a MWE as I keep the login information for myself):
library(RCurl)
library(jsonlite)
# Acccept cookies
curl <- getCurlHandle()
curlSetOpt(cookiejar = "/tmp/cookies.txt", curl = curl, verbose = T)
# Account information ----------------------------------------------
# Parameter list
prm <- list(baseUrl = "https://my.wirelesstag.net",
username = "user#user.com",
password = "password")
# Sign-in ----------------------------------------------------------
# Sign-in
invisible(
postForm(paste0(prm$baseUrl, "/ethAccount.asmx/SignIn"),
curl = curl,
.opts = list(
postfields = toJSON(list(
email = prm$username,
password = prm$password
)),
httpheader = c("Content-Type" = "application/json")
))
)
The entire log when executing postForm() is:
* Trying 130.211.169.89...
* TCP_NODELAY set
* Connected to my.wirelesstag.net (130.211.169.89) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:#STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: CN=my.wirelesstag.net
* start date: Jul 20 00:00:00 2017 GMT
* expire date: Oct 19 23:59:59 2019 GMT
* subjectAltName: host "my.wirelesstag.net" matched cert's "my.wirelesstag.net"
* issuer: C=US; O=GeoTrust Inc.; CN=RapidSSL SHA256 CA
* SSL certificate verify ok.
> POST /ethAccount.asmx/SignIn HTTP/1.1
Host: my.wirelesstag.net
Accept: */*
Content-Type: application/json
Content-Length: 58
* upload completely sent off: 58 out of 58 bytes
< HTTP/1.1 500 Internal Server Error
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Type: application/json; charset=utf-8
< Expires: -1
< Server: Microsoft-IIS/8.5
< jsonerror: true
< Date: Thu, 01 Mar 2018 11:27:33 GMT
< Content-Length: 1019
<
* Connection #0 to host my.wirelesstag.net left intact
Error: Internal Server Error

HTTP negotiation fails from Windows to Linux

I am trying to authenticate my local Windows 10 machine to a web service running inside a docker container. To be more specific, this container is running Hadoop services and a MIT Kerberos KDC. I have installed MIT Kerberos for Windows on my local machine and have successfully gotten a ticket hadoop/quickstart.cloudera#CLOUDERA from the KDC. When I authenticate with the same principal inside my container and call this command: curl -i --negotiate -u : "http://quickstart.cloudera:50070/webhdfs/v1/?op=GETFILESTATUS" I get a valid response. However, the same command run from my Windows machine returns this error:
Error 403 GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
Can anyone familiar with SSPI/GSSAPI give me some insight on what the problem here could be?
I have the environment variable KRB5CCNAME=<path to ccache> set correctly. This is the cURL info from my Windows command prompt:
curl 7.52.1 (x86_64-w64-mingw32) libcurl/7.52.1 WinSSL zlib/1.2.8 WinIDN libssh2/1.7.0_DEV
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz
Let me know if you need any more information about my environment setup.
Update:
Here is the full HTTP response from my Windows machine when I run the command with the -v flag added for verbosity.
* timeout on name lookup is not supported
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to quickstart.cloudera (127.0.0.1) port 50070 (#0)
> GET /webhdfs/v1/?op=GETFILESTATUS HTTP/1.1
> Host: quickstart.cloudera:50070
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 401 Authentication required
HTTP/1.1 401 Authentication required
< Cache-Control: must-revalidate,no-cache,no-store
Cache-Control: must-revalidate,no-cache,no-store
< Date: Fri, 10 Feb 2017 19:41:27 GMT
Date: Fri, 10 Feb 2017 19:41:27 GMT
< Pragma: no-cache
Pragma: no-cache
< Date: Fri, 10 Feb 2017 19:41:27 GMT
Date: Fri, 10 Feb 2017 19:41:27 GMT
< Pragma: no-cache
Pragma: no-cache
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1
< WWW-Authenticate: Negotiate
WWW-Authenticate: Negotiate
< Set-Cookie: hadoop.auth=; Path=/; HttpOnly
Set-Cookie: hadoop.auth=; Path=/; HttpOnly
< Content-Length: 1404
Content-Length: 1404
< Server: Jetty(6.1.26.cloudera.4)
Server: Jetty(6.1.26.cloudera.4)
<
* Ignoring the response-body
* Curl_http_done: called premature == 0
* Connection #0 to host quickstart.cloudera left intact
* Issue another request to this URL: 'http://quickstart.cloudera:50070/webhdfs/v1/?op=GETFILESTATUS'
* Found bundle for host quickstart.cloudera: 0x817220 [can pipeline]
* Re-using existing connection! (#0) with host quickstart.cloudera
* Connected to quickstart.cloudera (127.0.0.1) port 50070 (#0)
* Server auth using Negotiate with user ''
> GET /webhdfs/v1/?op=GETFILESTATUS HTTP/1.1
> Host: quickstart.cloudera:50070
> Authorization: Negotiate TlRMTVNTUAABAAAAt4II4gAAAAAAAAAAAAAAAAAAAAAKAFopAAAADw==
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 403 GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
HTTP/1.1 403 GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
< Cache-Control: must-revalidate,no-cache,no-store
Cache-Control: must-revalidate,no-cache,no-store
< Date: Fri, 10 Feb 2017 19:41:27 GMT
Date: Fri, 10 Feb 2017 19:41:27 GMT
< Pragma: no-cache
Pragma: no-cache
< Date: Fri, 10 Feb 2017 19:41:27 GMT
Date: Fri, 10 Feb 2017 19:41:27 GMT
< Pragma: no-cache
Pragma: no-cache
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1
< Set-Cookie: hadoop.auth=; Path=/; HttpOnly
Set-Cookie: hadoop.auth=; Path=/; HttpOnly
< Content-Length: 1546
Content-Length: 1546
< Server: Jetty(6.1.26.cloudera.4)
Server: Jetty(6.1.26.cloudera.4)
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 403 GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /webhdfs/v1/. Reason:
<pre> GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
* Curl_http_done: called premature == 0
* Closing connection 0
In contrast, this is the response from running the same command inside my container:
* About to connect() to quickstart.cloudera port 50070 (#0)
* Trying 172.18.0.2... connected
* Connected to quickstart.cloudera (172.18.0.2) port 50070 (#0)
> GET /webhdfs/v1/?op=GETFILESTATUS HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: quickstart.cloudera:50070
> Accept: */*
>
< HTTP/1.1 401 Authentication required
HTTP/1.1 401 Authentication required
< Cache-Control: must-revalidate,no-cache,no-store
Cache-Control: must-revalidate,no-cache,no-store
< Date: Fri, 10 Feb 2017 21:15:39 GMT
Date: Fri, 10 Feb 2017 21:15:39 GMT
< Pragma: no-cache
Pragma: no-cache
< Date: Fri, 10 Feb 2017 21:15:39 GMT
Date: Fri, 10 Feb 2017 21:15:39 GMT
< Pragma: no-cache
Pragma: no-cache
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1
< WWW-Authenticate: Negotiate
WWW-Authenticate: Negotiate
< Set-Cookie: hadoop.auth=; Path=/; HttpOnly
Set-Cookie: hadoop.auth=; Path=/; HttpOnly
< Content-Length: 1404
Content-Length: 1404
< Server: Jetty(6.1.26.cloudera.4)
Server: Jetty(6.1.26.cloudera.4)
<
* Ignoring the response-body
* Connection #0 to host quickstart.cloudera left intact
* Issue another request to this URL: 'http://quickstart.cloudera:50070/webhdfs/v1/?op=GETFILESTATUS'
* Re-using existing connection! (#0) with host quickstart.cloudera
* Connected to quickstart.cloudera (172.18.0.2) port 50070 (#0)
* Server auth using GSS-Negotiate with user ''
> GET /webhdfs/v1/?op=GETFILESTATUS HTTP/1.1
> Authorization: Negotiate YIICkQYJKoZIhvcSAQICAQBuggKAMIICfKADAgEFoQMCAQ6iBwMFAAAAAACjggGBYYIBfTCCAXmgAwIBBaEKGwhDTE9VREVSQaImMCSgAwIBA6EdMBsbBEhUVFAbE3F1aWNrc3RhcnQuY2xvdWRlcmGjggE8MIIBOKADAgESoQMCAQKiggEqBIIBJnWbXp9WlAVk0nGIqD7T25On1+OCPzXDX/aoH01FTjJbEwrYj4cMML7Tf6jaKDIANEh57kTJOvPknL3CWHI1c3LeNpt1Ir8H2M3Zvk91HpbWXzv5WJTeUOK9L6zTaKFEs/dKQgD7VzmHKDJtMyVKQWLLVU8JuyKAV6iM4FvxfZ+WDF8QCk7pxwjgX1OT7jv9jR28MPpsIweqUYYnneJxVTsxgmsHdOvj5wpMGy9RA9R8jtR+Wh3l5r3a3zcUTmGwAqY+NXhBkviSTw+DgitnipYh5tXBRhNqGfk86qWAdodGgL+SdkwwGsq91PyYQiMCLXjWx90aBOEFeZLDyqBaXlMIZ3TT3urUQEuB206+8KNw1n6N6+u+ZY4QT7NJyVZqHbnOR5V5maSB4TCB3qADAgESooHWBIHTyaBY3PormkycaX9uf/lLe6ISYnItZikJqslAGpJVnla2HXYvhFjqn5yr8td1pw3zzdnDEZx3a9EylIrRQD5IoIvHCzd0mlJhHFj4xxISM5hxlMiL8DewMjGsVcDveqpHw1SyxIsrEPOhe62HuRXS7c1Z9kYkP6KldzyAJOttOVYCuL36hOxwEFqJtbWk1/f9gfTdzmxQmEASM3/wsj2Q/WYCZY/hazDIz6dmHsyla/F6NXGK0BwRnHHBCqSHe7GdWmBDNjHiuo6R0/YvqTl5Uvf0Rw==
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: quickstart.cloudera:50070
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Cache-Control: no-cache
Cache-Control: no-cache
< Expires: Fri, 10 Feb 2017 21:15:39 GMT
Expires: Fri, 10 Feb 2017 21:15:39 GMT
< Date: Fri, 10 Feb 2017 21:15:39 GMT
Date: Fri, 10 Feb 2017 21:15:39 GMT
< Pragma: no-cache
Pragma: no-cache
< Expires: Fri, 10 Feb 2017 21:15:39 GMT
Expires: Fri, 10 Feb 2017 21:15:39 GMT
< Date: Fri, 10 Feb 2017 21:15:39 GMT
Date: Fri, 10 Feb 2017 21:15:39 GMT
< Pragma: no-cache
Pragma: no-cache
< Content-Type: application/json
Content-Type: application/json
< Set-Cookie: hadoop.auth="u=hadoop&p=hadoop/quickstart.cloudera#CLOUDERA&t=kerberos&e=1486797339425&s=BqBHGJ+/FxxeSR0ayBXHOrfPkwU="; Path=/; HttpOnly
Set-Cookie: hadoop.auth="u=hadoop&p=hadoop/quickstart.cloudera#CLOUDERA&t=kerberos&e=1486797339425&s=BqBHGJ+/FxxeSR0ayBXHOrfPkwU="; Path=/; HttpOnly
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Server: Jetty(6.1.26.cloudera.4)
Server: Jetty(6.1.26.cloudera.4)
<
* Connection #0 to host quickstart.cloudera left intact
* Closing connection #0
{"FileStatus":{"accessTime":0,"blockSize":0,"childrenNum":5,"fileId":16385,"group":"supergroup","length":0,"modificationTime":1459909590753,"owner":"hdfs","pathSuffix":"","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"}}
The answer is very easy in this case. Curl on Windows is compiled with SSPI. When SSPI is requested to perform SPNEGO, it tries Kerberos, which fails here. Likely "Server not found in database" (use Wireshark) and then falls back to NTLM. It sends a raw NTLM token to your JGSS-backed server which rejects the token because
This is not a SPNEGO wrapped token, but a raw NTLM token
Java does not support NTLM
Here is sample code how to intercept this and respond with a meaningful message. Raise an issue with Hadoop.
Moreover, your Curl version 7.19.7 on Linux is extremely old and unsecure, you should upgrade immediately AND the SPNEGO Authenticator on Jetty is broken because it does not respond with a context-completion token. To sum up, the entire authentication should not be trusted because it is faulty. See RFC 7546.

unable to connect R through proxy

I´m trying to scrape a web page using a proxy but something isn´w working.
Here is an httr attemp to set the proxy options, below i try with RCurl.
I´ve read several answers regarding the subject but they don´t seem to be working.
Any suggestions?
### httr attempt
set_config(
use_proxy(url="proxy.xxx.com.ar", port=8080,
username = "xxxx\\xxxx", password = "xxxxx"),
override = TRUE
)
a <- GET("http://google.com/", verbose())
-> GET http://google.com/ HTTP/1.1
-> Proxy-Authorization: Basic dG1vdmlsZXNcbWFyYmVsOkFyYWNhbGFjYW5hMjM=
-> User-Agent: curl/7.19.7 Rcurl/1.95.4.1 httr/0.4.0.99
-> Host: google.com
-> Accept: */*
-> Accept-Encoding: gzip
-> Proxy-Connection: Keep-Alive
->
<- HTTP/1.1 407 Proxy Authentication Required
<- Server: pxsip02-srv.xxxxx.com.ar
<- Date: Mon, 11 Aug 2014 15:11:14 GMT
<- Content-Length: 309
<- Content-Type: text/html
<- Connection: Keep-Alive
<- Keep-Alive: timeout=60, max=8
<- Proxy-Authenticate: NTLM
<-
content(a)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head><title>Authentication Error</title></head>
<body>
<h1>Authentication Error</h1>There has been an error validating your user credentials. If the error persists,contact your network administrator.<br>Proxy authentication required<br><hr>
<br>Details: 407 Proxy Authentication Required</body>
</html>
### RCurl attempt
library("RCurl")
opts <- list(
proxy = "proxy.xxxxx.com.ar",
proxyusername = "xxxxxx\\xxxxx",
proxypassword = "xxxxxx",
proxyport = 8080,
capath = system.file("CurlSSL", "cacert.pem", package = "RCurl"),
verbose=TRUE, proxyauth=TRUE, useragent= "", header = TRUE
)
options( RCurlOptions = opts)
getURL("http://stackoverflow.com")
* About to connect() to proxy proxy.xxxxx.com.ar port 8080 (#0)
* Trying 10.167.195.11... * connected
* Connected to proxy.xxxxxx.com.ar (10.167.195.11) port 8080 (#0)
* Proxy auth using Basic with user 'xxxxxxx\xxxxx'
> GET http://stackoverflow.com HTTP/1.1
Proxy-Authorization: Basic VE1PVklMRVNcTUFSQkVMOkFyYWNhbGFjYW5hMjM=
Host: stackoverflow.com
Accept: */*
Proxy-Connection: Keep-Alive
[1] "HTTP/1.1 407 Proxy Authentication Required\r\nServer: pxsip02-srv.xxxx.com.ar\r\nDate: Mon, 11 Aug 2014 15:15:29 GMT\r\nContent-Length: 309\r\nContent-Type: text/html\r\nConnection: Keep-Alive\r\nKeep-Alive: timeout=60, max=8\r\nProxy-Authenticate: NTLM\r\n\r\n<html><head><title>Authentication Error</title></head><body><h1>Authentication Error</h1>There has been an error validating your user credentials. If the error persists,contact your network administrator.<br/>Proxy authentication required<br/><hr/><br/>Details: 407 Proxy Authentication Required</body></html>"
< HTTP/1.1 407 Proxy Authentication Required
< Server: pxsip02-srv.xxxxxxx.com.ar
< Date: Mon, 11 Aug 2014 15:15:29 GMT
< Content-Length: 309
< Content-Type: text/html
< Connection: Keep-Alive
< Keep-Alive: timeout=60, max=8
< Proxy-Authenticate: NTLM
<
* Connection #0 to host proxy.xxxxxx.com.ar left intact
Here is the update of the previous question. I add it as another answer so it´s easier to follow.
GET("http://google.com/",
config = list(
use_proxy(url="proxy.xxx.com.ar", port=8080,
username = "xxxx\\xxxx", password = "xxxxx",
proxyauth = 1)
)
)
The error messege:
Error in use_proxy(url = "proxy.xxxx.com.ar", port = 8080, username = "xxxxxx\\xxxx", :
unused argument (proxyauth = 1)

How to reduce the error message in FOSRestBundle?

I am using FOSRestBundle.
I am using a GET request and I am expecting an 404 error message, but it is very long.
Here is the definition of the action() method:
/**
* #Rest\View
* #Rest\Get("/api/test/{id}",
* requirements={"id" = "\d+"},
* defaults={"id" = 1}
* )
*/
public function getAction($id) {
$repo = $this->getDoctrine()->
getManager()->
getRepository("MinnAdsAPIBundle:Test");
$entity = $repo->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find test entity!');
}
return array('test' => $entity);
}
To check the request, I used this shell command: curl -i http://localhost/tuto/web/app_dev.php/api/test/16654
The result is:
HTTP/1.1 404 Not Found
Date: Fri, 11 Apr 2014 07:33:13 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.4
Set-Cookie: PHPSESSID=r5fjnf14fp0oou8ac8hu60vru7; path=/
Cache-Control: no-cache
Vary: Accept-Language
X-Debug-Token: 97fd81
Transfer-Encoding: chunked
Content-Type: application/json
[{"message":"Unable to find test entity!","class":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/home\/amine\/NetBeansProjects\/tuto\/vendor\/symfony\/symfony\/src\/Symfony\/Bundle\/FrameworkBundle\/Controller\/Controller.php","line":149,"args":[]},{"namespace":"Symfony\\Bundle\\FrameworkBundle\\Controller","short_class":"Controller","class":"Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller","type":"->","function":"createNotFoundException","file":"\/home\/amine\/NetBeansProjects\/tuto\/src\/Minn\/AdsAPIBundle\/Controller\/TestController.php","line":31,"args":[["string","Unable to find test entity!"]]},{"namespace":"Minn\\AdsAPIBundle\\Controller","short_class":"TestController","class":"Minn\\AdsAPIBundle\\Controller\\TestController","type":"->","function":"getAction","file":null,"line":null,"args":[["string","155"]]},{"namespace":"","short_class":"","class":"","type":"","function":"call_user_func_array","file":"\/home\/amine\/NetBeansProjects\/tuto\/app\/bootstrap.php.cache","line":2841,"args":[["array",[["object","Minn\\AdsAPIBundle\\Controller\\TestController"],["string","getAction"]]],["array",[["string","155"]]]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"HttpKernel","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","function":"handleRaw","file":"\/home\/amine\/NetBeansProjects\/tuto\/app\/bootstrap.php.cache","line":2815,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"HttpKernel","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->","function":"handle","file":"\/home\/amine\/NetBeansProjects\/tuto\/app\/bootstrap.php.cache","line":2944,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\\Component\\HttpKernel\\DependencyInjection","short_class":"ContainerAwareHttpKernel","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->","function":"handle","file":"\/home\/amine\/NetBeansProjects\/tuto\/app\/bootstrap.php.cache","line":2245,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"],["string","1"],["boolean",true]]},{"namespace":"Symfony\\Component\\HttpKernel","short_class":"Kernel","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->","function":"handle","file":"\/home\/amine\/NetBeansProjects\/tuto\/web\/app_dev.php","line":29,"args":[["object","Symfony\\Component\\HttpFoundation\\Request"]]}]}]
The message I am expecting is:
HTTP/1.1 404 Not Found
Date: Fri, 11 Apr 2014 07:33:13 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.4
Set-Cookie: PHPSESSID=r5fjnf14fp0oou8ac8hu60vru7; path=/
Cache-Control: no-cache
Vary: Accept-Language
X-Debug-Token: 97fd81
Transfer-Encoding: chunked
Content-Type: application/json
{"message":"Unable to find test entity!"}
Is there any idea to achieve that?
thanks,
#amine put in your terminal this commande:
curl -i http://localhost/tutonew/web/api/test/16654
!!!

Resources