Errors Updating channels | ThingSpeak API | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.
Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Errors Updating channels
No permission to create posts
September 18, 2012
10:27 pm
Avatar
amcclung
New Member
Members
Forum Posts: 1
Member Since:
September 18, 2012
sp_UserOfflineSmall Offline
I'm new to this, so I'm probably doing something stupid, but after hours of searching I can't really say what it is I'm doing wrong.

I'm trying to update my channel with some data in a little Processing (Java) app. Both GET and POST are failing on me. Here is the code I'm using for GET:

String data = "field1=" + mCurrentTemperature;
String apiKey = "V8BTEQWV9A8FRQ3U";

mClient = new Client(this, "api.thingspeak.com", 80);
mClient.write("GET /update?key=" + apiKey + "&field1=" + mCurrentTemperature + " HTTP/1.0\n");
mClient.write("Host: 127.0.0.1\n\n");

The response I get is this:
HTTP/1.1 301 Moved Permanently
Server: nginx/0.8.53
Date: Wed, 19 Sep 2012 03:21:06 GMT
Content-Type: text/html
Content-Length: 185
Connection: close
Location: https://www.thingspeak.com/?key=V8BTEQWV9A8FRQ3U&field1=73.292

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/0.8.53</center>
</body>
</html>

Which seems weird to me.

Perhaps even weirder is when I try to use POST:

String data = "field1=" + mCurrentTemperature;
String apiKey = "V8BTEQWV9A8FRQ3U";
  
mClient = new Client(this, "api.thingspeak.com", 80);
mClient.write("POST /update HTTP/1.1\n");
mClient.write("Host: api.thingspeak.com\n");
mClient.write("Connection: close\n");
mClient.write("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
mClient.write("Content-Type: application/x-www-form-urlencoded\n");
mClient.write("Content-Length: ");
mClient.write( data.length() );
mClient.write("\n\n");
mClient.write( data );

The response I get back from that is:

Client says: HTTP/1.1 411 Length Required
Server: nginx/0.8.53
Date: Wed, 19 Sep 2012 03:24:59 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/0.8.53</center>
</body>
</html>

But I've specified Content-Length explicitly. Am I calculating it wrong?

I'm really hoping someone can shed some light on what's going here because I'm totally stumped!
September 19, 2012
11:03 pm
Avatar
Hans
Natick, MA

Admin
Forum Posts: 411
Member Since:
January 18, 2011
sp_UserOfflineSmall Offline

Hmm… everything looks right. What microcontroller is sending that request?

Can you try making the GET HTTP 1.1?

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
29 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormier

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457