So I've got an arduino uno with a CC3000 shield attached and I want to push data to my Xively account:
https://xively.com/develop/yS4XfViIIEEkB94MJ4zs
However I get this error when I connect:
Connected!
Request DHCP
api.xively.com -> 64.94.18.120
Data Lengthz
PUT /v2/feeds/97346308.json HTTP/1.1
Host: api.xively.com
X-ApiKey:mykey
Content-Length: z
Connection: close
{"version":"1.0.0","datastreams" : [ {"id" : "Longitude","current_value" : ""},{"id" : "Latitude","current_value" : ""}]}
Connected to Xively server.
--------------------------------------
HTTP/1.1 411 Length Required
Date: Fri, 08 Aug 2014 13:19:33 GMT
Content-Type: text/html
Content-Length: 181
Connection: close
<html>
<head><title>411 Length Required</title></head>
<body bgcolor="white">
<center><h1>411 Length Required</h1></center>
<hr><center>nginx/1.1.19</center>
</body>
</html>
I understand that error 411 is a call for content length but I've alread declared this in my header and I still get this error.
Any help would be greatly appreciated :)
The Content-Length value must be a sequence of digits. What you sent is a letter, so the server complained that it didn't get your header in the correct format.
Instead of:
Content-Length: z
Use:
Content-Length: 0
If you are actually including data in the body of your request, the length should be the number of octets in the encoded body.
Related
I'm working on centos 7 and has this json request :
curl --output 'json.data.json' -vvv -x '' -X POST -H "Content-Type: application/json" -H "Connection: keep-alive" -d '{"jsonrpc":"2.0","method":"item.get","params":{"output": ["name","lastvalue","lastclock","hostid"],"groupids": ["5"],"filter":{"name":["LDT Security Flag"]},"sortfield": "name" },"auth":"c1cxxxxxxxxx","id":1}' $CURLADDR
Now,
In middle of results I see :
734247","lastvalue":"0"},{"itemid":"192890","name":"LDT Fl* transfer closed with outstanding read data remaining
100 86797 0 86569 100 228 75094 197 0:00:01 0:00:01 --:--:-- 75146
* Closing connection 0
curl: (18) transfer closed with outstanding read data remaining
And after that some more json results.
But I noticed that not matter how many times I run it and redirect output to .json file , file always at the same size : 88K like there some kind of limit on info download size ? what can i do ?
UPDATE:
So i added it and now the error : curl: (18) transfer closed with outstanding Read data remaining is gone. but is still cuts at the middle with : * Closing Connection 0 and file is 88K – Batchen Regev 11 mins ago
also connection data :
> POST /api_jsonrpc.php HTTP/1.0
> User-Agent: curl/7.29.0
> Host: XXXXXX:1080
> Content-Type: application/json;charset=utf-8
> Accept: application/json, text/plain, */*
> Content-Length: 224
>
} [data not shown]
* upload completely sent off: 224 out of 224 bytes
100 224 0 0 100 224 0 223 0:00:01 0:00:01 --:--:-- 223< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 25 Dec 2018 15:21:07 GMT
< Content-Type: application/json
< Connection: close
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Content-Type
< Access-Control-Allow-Methods: POST
< Access-Control-Max-Age: 1000
<
{ [data not shown]
100 86840 0 86616 100 224 77583 200 0:00:01 0:00:01 --:--:-- 77612
* Closing connection 0
This seems to be a server side issue.
You might try to work it around by forcing HTTP 1.0 connection (to avoid chunked transfer which might cause this problem) with the --http1.0 option.
CURLE_PARTIAL_FILE (18)
A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that doesn't match the previously given size.
Source: https://curl.haxx.se/libcurl/c/libcurl-errors.html
Background: I am using cfhttp and an auth token provided to me by a vendors API to do two GET calls. The first one fails the second is successful.
Call #1 is supposed to return a list of Order ID's in JSON format.
Call #2 uses one of those Order ID's to return a full order again in JSON format.
The calls are outlined below:
Request all of the ORDER ID's
<cfhttp method="get" url="https://test-9832.APIURL.com/criminal_api//1.0/service/requests" result="orderFirst">
<cfhttpparam type="Header" name="Authorization" value="Bearer 5BDCECFBDBE4680E74C8B81A58EAC544">
</cfhttp>
Request a full order based on the same auth token and one of the Order Ids returned in the previous step:
<cfhttp method="get" url="https://test-9832.APIURL.com/criminal_api//1.0/service/requests/WB-042916-YH59Z-PL-001" result="orderFull">
<cfhttpparam type="Header" name="Authorization" value="Bearer 5BDCECFBDBE4680E74C8B81A58EAC544">
</cfhttp>
The calls are using the same exact cfhttpparam and value the only difference is the URL. The vendor mentioned they sometimes see issues if the Auth Token is double encoded. I am setting the auth token value statically at this point just to get it to work.
Below is a cfdump of what is returned in Step #1 that fails:
struct
Charset UTF-8
ErrorDetail [empty string]
Filecontent Connection Failure
Header HTTP/1.1 200 OK Connection: close Expires: Wed, 31 Dec 1969 16:00:00 PST Date: Wed, 14 Sep 2016 04:47:01 GMT Server: hws Pragma: No-cache Cache-Control: no-cache Set-Cookie: X-HR-ClientSessionId=2_12.161.115.226_1473828421271;Secure; path=/; HttpOnly Content-Type: application/json;charset=UTF-8
Mimetype application/json
Responseheader
struct
Cache-Control no-cache
Connection close
Content-Type application/json;charset=UTF-8
Date Wed, 14 Sep 2016 04:47:01 GMT
Expires Wed, 31 Dec 1969 16:00:00 PST
Explanation OK
Http_Version HTTP/1.1
Pragma No-cache
Server hws
Set-Cookie X-HR-ClientSessionId=2_12.161.115.226_1473828421271;Secure; path=/; HttpOnly
Status_Code 200
Statuscode 200 OK
Text NO
The status code is showing 200 OK but the file contents is Connection Failure.
QUESTION: Is there anything else I can add to my script to help debug or test?
I have an image saved on my AWS S3 bucket. This is my CORS configuration:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Also, the bucket has this policy:
{
"Version": "2012-10-17",
"Id": "Policy1468082822770",
"Statement": [
{
"Sid": "Stmt1468082812651",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::criptolibertad/*"
}
]
}
This is the image: https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg , as you can see, it is public. I use a library called Croppie that tries to load the image into a canvas. But the canvas doesn't show the image I don't know why. The js looks like this:
croppie_div.croppie('bind', {
url: "{{ carta_magicpy.imagen_base.url }}",
points: [10,10,300,600]
});
That url attribute is just a variable rendered by Django. It looks like this when it is rendered:
<img style="opacity: 0;" src="https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg" crossorigin="anonymous" class="cr-image">
Notice the crossorigin attribute. I went into Croppie's source and removed that attribute. But then I get the error:
Image from origin ... has been blocked from loading by Cross-Origin Resource Sharing policy:
No 'Access-Control-Allow-Origin' header is present on the requested
resource
How can I solve this?
Seems the CORS headers are still not set correctly. This related Croppie issue #119 mentions you can check that by looking at the response headers.
It's pretty easy to inspect the headers with curl, for the image stored in your bucket:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" https://criptolibertad.s3.amazonaws.com/Django/0_startproject.jpeg
HTTP/1.1 200 OK
x-amz-id-2: 9AaMwS9s2Im+OV6YlzVKrDW8RnbQqFt4Ygc+pRa3XM4iDmnJqlO8DQ7EjvpT4W4GnhGc0IvoQeI=
x-amz-request-id: CD4E7C50B5186192
Date: Fri, 15 Jul 2016 07:54:52 GMT
Last-Modified: Sat, 09 Jul 2016 05:13:33 GMT
ETag: "5733f7cd0187eb3a840bbe83e2c66a9b"
Accept-Ranges: bytes
Content-Type: image/jpeg
Content-Length: 33402
Server: AmazonS3
As opposed to the properly set up CORS headers on e.g imgur:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" http://i.imgur.com/HMf7XWD.jpg
HTTP/1.1 200 OK
Last-Modified: Wed, 06 Jul 2016 15:07:13 GMT
ETag: "7b01be4b9235542038f6d9793cc2c620"
Content-Type: image/jpeg
Fastly-Debug-Digest: f94b623450bb8143aff369600bf855d6332bb44c12070f02b0fc95648eac6ef3
cache-control: public, max-age=31536000
Content-Length: 2457350
Accept-Ranges: bytes
Date: Fri, 15 Jul 2016 07:55:15 GMT
Age: 277937
Connection: keep-alive
X-Served-By: cache-iad2131-IAD, cache-fra1232-FRA
X-Cache: HIT, HIT
X-Cache-Hits: 1, 1
X-Timer: S1468569315.725739,VS0,VE2
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Origin: *
Server: cat factory 1.0
As you can see the main difference is that imgur returns the headers Access-Control-Allow-Methods and Access-Control-Allow-Origin, while your S3 bucket does not.
I have followed the official Amazon documentation on the subject and applied the modified CORS configuration to my own bucket, the difference from your configuration is the AllowedHeader element, which defines the headers to allowed in response. I set my bucket to:
<AllowedHeader>*</AllowedHeader>
Here are the resulting headers on the image stored in my bucket:
curl -I -H "Origin: https://stackoverflow.com/questions/38365182" -H "Access-Control-Request-Method: GET" https://so38134984.s3.amazonaws.com/rainbow_dash.png
HTTP/1.1 200 OK
x-amz-id-2: ANxPKoL3JDsLDGerTf8gdcyRU7U4Ozg4eMYJ9ADlX/2qcBmx0dsmAbZxv2h/tFfQIXbkAs+x5iA=
x-amz-request-id: 737E30AE2F8634FC
Date: Fri, 15 Jul 2016 07:53:55 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Max-Age: 3000
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
Last-Modified: Mon, 04 Jul 2016 20:09:19 GMT
ETag: "3ad1bb64b913c2eadab216b96034b990"
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 148647
Server: AmazonS3
I assume my image will now work properly in your Croppie script.
I'm using rest request in soapUI.
I want to save the JSON request and response to a file.
How can i do it?
Request payload (JSON) is not included in the report. Only request HTTP headers are captured in the report. Please let me know if you are able to log request JSON. I am using SoapUI 5.0.0
Right click on your testSuite and select Launch TestRunner, on Launch TestRunner panel select Reports tab, on this tab check Exports all results, and select a root folder to save this results on Root Folder:. Finally click on Launch.
Then in your root folder for each request you will have a file like TestSuiteName-TestCaseName-TestStepName-nIteration-result.txt with following content:
Status: OK
Time Taken: 409
Size: 793
Timestamp: Mon Apr 07 12:47:02 CEST 2014
TestStep: Test Request
----------------- Messages ------------------------------
----------------- Properties ------------------------------
Encoding: UTF-8
Endpoint: http://myHost.com/service/service
---------------- Request ---------------------------
Request Headers: Host : XX.XXX.X.XX
Content-Length : 321
SOAPAction : "http://myAction.com"
Accept-Encoding : gzip,deflate
User-Agent : Apache-HttpClient/4.1.1 (java 1.5)
Connection : Keep-Alive
Content-Type : text/xml;charset=UTF-8
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<element/>
<element/>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
---------------- Response --------------------------
Response Headers: Date : Mon, 07 Apr 2014 10:48:34 GMT
#status# : HTTP/1.1 200
Content-Length : 793
Expires : Thu, 01 Jan 1970 00:00:00 GMT
Content-Type : text/xml; charset=UTF-8
Connection : close
Server : XXXXXXXXXXXX
Cache-Control : no-cache
Pragma : no-cache
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If you prefer to save only request and response with no additional information you can take a look on this and this.
Hope this helps,
Started getting 500 error when trying to execute gapi.client.drive.files.list, even using the API exprorer.
Authorization works fine.
request:
GET https://www.googleapis.com/drive/v2/files?key={YOUR_API_KEY}
Authorization: Bearer ZZZZZZZZZZZZZ
X-JavaScript-User-Agent: Google APIs Explorer
response:
500 Internal Server Error
cache-control: private, max-age=0
content-encoding: gzip
content-length: 66
content-type: application/json; charset=UTF-8
date: Thu, 28 Mar 2013 01:24:28 GMT
expires: Thu, 28 Mar 2013 01:24:28 GMT
server: GSE
{
"error": {
"code": 500,
"message": null
}
}
It was working yesterday.
Update
Apparently it works if I limit the result set to 19 (no query string) or 13 (q: 'root' in parents)
I guess Google developers introduced some kind of limit yesterday?
Or may be I have an invalid file entry which started chrashing the google server?
How can I investigate?
Thanks!