Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problem with Post calls
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Codomaniac  
View profile  
 More options Oct 12 2010, 2:27 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Mon, 11 Oct 2010 23:27:39 -0700 (PDT)
Local: Tues, Oct 12 2010 2:27 am
Subject: Problem with Post calls
Hi.
I am trying to post comment on an Object (that is, a post, checkin,
photopost etc)
The problem is that a Post call with out a parameter works (this too
faces trouble at times), but the calls with Parameters don't work and
i get 417 Http Status or at times 500.

for example, here is what i am doing for testing purposes

        HttpPost request=new HttpPost("http://brightkite.com/places/
4d65bf3e648846b767bc58e6fc5cee12/checkins.xml");
        consumer.sign(request);

        List <NameValuePair> parameters = new
ArrayList<NameValuePair>();
        parameters.add(new BasicNameValuePair("comment[comment]", "I'm
hopeful"));

        UrlEncodedFormEntity sendentity = new
UrlEncodedFormEntity(parameters, HTTP.UTF_8);

        request.setHeader("Content-Type","application/x-www-form-
urlencoded");
        request.setEntity(sendentity);

        HttpResponse response=httpClient.execute(request);

        int status=response.getStatusLine().getStatusCode();

        System.out.println("Returned status -> "+status);

        InputStream is2= response.getEntity().getContent();
        for (int i = is2.read(); i > -1; i = is2.read()) {
                System.out.write(i);
        }
--------------------------------------------------------------------------- ---------------------------------------------------------------------

What am i doing wrong? I have tried many things but the most
appropriate to me is what i have shared here. Any help would be great.
I have developed a Java wrapper for Brightkite Api, however, this is
the only thing missing (i.e posting comments and creating objects). By
the way Likes call doesn't work too, I get a success response but
Likes don't appear !


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LJHarb  
View profile  
 More options Oct 12 2010, 2:31 am
From: LJHarb <jor...@brightkite.com>
Date: Mon, 11 Oct 2010 23:31:54 -0700 (PDT)
Local: Tues, Oct 12 2010 2:31 am
Subject: Re: Problem with Post calls
Hi -

  Signing the OAuth call means you're ensuring that after it's been
signed, the call does not change (that's the security OAuth provides -
preventing tampering with authenticated calls). Thus, you have to add
your parameters BEFORE you sign the OAuth call - adding a parameter
afterwards is tantamount to tampering with the call.

  Let me know if this helps.

- Jordan

On Oct 11, 11:27 pm, Codomaniac <mauze_muaw...@hotmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 12 2010, 2:33 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Mon, 11 Oct 2010 23:33:02 -0700 (PDT)
Local: Tues, Oct 12 2010 2:33 am
Subject: Re: Problem with Post calls
and By the way "consumer" is

OAuthConsumer consumer=new
CommonsHttpOAuthConsumer(ConsumerKey,ConsumerSecret);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 12 2010, 8:31 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Tue, 12 Oct 2010 05:31:36 -0700 (PDT)
Local: Tues, Oct 12 2010 8:31 am
Subject: Re: Problem with Post calls
Indeed you are right, i must have forgotten to post the correct code.
However, doing what you told me to , I get following response ...

Returned status -> 417
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-
family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /places/4d65bf3e648846b767bc58e6fc5cee12/checkins.xml HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth
oauth_token="NTQ5ZWEzYWQ1NmVmNDM5ZjczNzJkMGEx",
oauth_consumer_key="M2Y1ODYxYjI1ZDkzMmY0OGI0OGY0ZTU4",
oauth_version="1.0", oauth_signature_method="HMAC-
SHA1", oauth_timestamp="1286886342",
oauth_nonce="-1429113925153201057",
oauth_signature="MjotZ5KUecMoiQrP5cq3uRwQ8Kk%3D"
Content-Length: 34
Host: brightkite.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.0-beta1 (java 1.4)
Expect: 100-Continue

</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>

<P>
Some aspect of the HTTP Request is invalid.  Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is <A HREF="mailto:root">root</A>.

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Tue, 12 Oct 2010 12:24:59 GMT by gateway.csquareonline.local
(squid/2.7.STABLE6)
</ADDRESS>
</BODY></HTML>

......... Corrected code..........

HttpPost request=new HttpPost("http://brightkite.com/places/
4d65bf3e648846b767bc58e6fc5cee12/checkins.xml");

List <NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("comment[comment]", "xyz
comment"));

UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters,
HTTP.UTF_8);
request.setHeader("Content-Type","application/x-www-form-urlencoded");
request.setEntity(sendentity);

consumer.sign(request);
HttpResponse response=httpClient.execute(request);

int status=response.getStatusLine().getStatusCode();

System.out.println("Returned status -> "+status);

InputStream is2= response.getEntity().getContent();
for (int i = is2.read(); i > -1; i = is2.read()) {
        System.out.write(i);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LJHarb  
View profile  
 More options Oct 12 2010, 2:44 pm
From: LJHarb <jor...@brightkite.com>
Date: Tue, 12 Oct 2010 11:44:59 -0700 (PDT)
Local: Tues, Oct 12 2010 2:44 pm
Subject: Re: Problem with Post calls
It looks like you're trying to post a comment to a place - comments
can only be posted on objects. Objects are checkins, posts, tips, etc.

Check out http://api.brightkite.com/objects.html for the parameters
you need to do a correct checkin.

- Jordan

On Oct 12, 5:31 am, Codomaniac <mauze_muaw...@hotmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 13 2010, 12:50 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Tue, 12 Oct 2010 21:50:33 -0700 (PDT)
Local: Wed, Oct 13 2010 12:50 am
Subject: Re: Problem with Post calls
That wasn't working, i had checked it too(as i said, i have tried many
things). In the following piece of code i am trying to comment on a
checkin

<checkin>
    <watched type="boolean">false</watched>
    <object_type>checkin</object_type>
    <share_with>only me</share_with>
    <tip type="boolean">false</tip>
    <ratings_count type="integer">0</ratings_count>
    <via>web</via>
    <public type="boolean">false</public>
    <creator>
      <fullname>T-Rex</fullname>
      <blocking_me type="boolean">false</blocking_me>
      <avatar_url>http://brightkite.com/images/
default_user_avatar.png</avatar_url>
      <login>khaptman</login>
      <small_avatar_url>http://brightkite.com/images/
default_user_avatar-small.png</small_avatar_url>
      <smaller_avatar_url>http://brightkite.com/images/
default_user_avatar-smaller.png</smaller_avatar_url>
      <tiny_avatar_url>http://brightkite.com/images/
default_user_avatar-tiny.png</tiny_avatar_url>
      <id>0f017c81665fba5729d2789c3bf7f58e</id>
    </creator>
    <is_public type="boolean">false</is_public>
    <rating type="integer">0</rating>
    <comments_count type="integer">0</comments_count>
    <created_at_with_tz>Thursday, September 23, 2010 05:04:23Z</
created_at_with_tz>
    <place>
      <scope>address</scope>
      <latitude type="float">24.906667</latitude>
      <display_location>Karachi, Pakistan</display_location>
      <longitude type="float">67.160833</longitude>
      <name>Quaid-e-azam Intl</name>
      <id>416ba9feae62798858c66b9cc55b5fa8</id>
    </place>
    <view_count type="integer">61</view_count>
    <created_at_ts>1285218263.327000</created_at_ts>
    <id>aa6f52d903ec8407417238a609314a2b</id>
    <created_at_as_words>19 days</created_at_as_words>
    <created_at type="datetime">2010-09-23T05:04:23Z</created_at>
    <about type="boolean">false</about>
  </checkin>

Id of this checkin is "aa6f52d903ec8407417238a609314a2b" .... when I
try to comment on it (with following code)

  HttpPost request=new HttpPost("http://brightkite.com/objects/
aa6f52d903ec8407417238a609314a2b/comments.xml");

        List <NameValuePair> parameters = new
ArrayList<NameValuePair>();
        parameters.add(new BasicNameValuePair("comment[comment]", "xyz
comment"));

        UrlEncodedFormEntity sendentity = new
UrlEncodedFormEntity(parameters, HTTP.UTF_8);
        request.setEntity(sendentity);

        request.setHeader("Content-Type","application/x-www-form-
urlencoded");

        consumer.sign(request);

        HttpResponse response=httpClient.execute(request);

        int status=response.getStatusLine().getStatusCode();

        System.out.println("Returned status -> "+status);

        InputStream is2= response.getEntity().getContent();
        for (int i = is2.read(); i > -1; i = is2.read()) {
                System.out.write(i);
        }

--------------------------------------------------------------------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------------------------
I get the same error....

Returned status -> 417
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-
family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to process the request:
<PRE>
POST /objects/aa6f52d903ec8407417238a609314a2b/comments.xml HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: OAuth
oauth_token="MGNjMTFhMzFiMTExY2JjNGMzM2VmZDVh",
oauth_consumer_key="M2Y1ODYxYjI1ZDkzMmY0OGI0OGY0ZTU4",
oauth_version="1.0", oauth_signature_method="HMAC-
SHA1", oauth_timestamp="1286945372", oauth_nonce="
7549350979876047373",
oauth_signature="egZq3RGEYiCpU3ZqSBgeaGRzX%2F4%3D"
Content-Length: 34
Host: brightkite.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.0-beta1 (java 1.4)
Expect: 100-Continue

</PRE>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Invalid Request
</STRONG>
</UL>

<P>
Some aspect of the HTTP Request is invalid.  Possible problems:
<UL>
<LI>Missing or unknown request method
<LI>Missing URL
<LI>Missing HTTP Identifier (HTTP/1.0)
<LI>Request is too large
<LI>Content-Length missing for POST or PUT requests
<LI>Illegal character in hostname; underscores are not allowed
</UL>
<P>Your cache administrator is <A HREF="mailto:root">root</A>.

<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Wed, 13 Oct 2010 04:48:45 GMT by gateway.csquareonline.local
(squid/2.7.STABLE6)
</ADDRESS>
</BODY></HTML>

--------------------------------------------------------------------------- --------------------------------------------------------------------------- --------------------------------------------------------------------------- ----------------------------


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LJHarb  
View profile  
 More options Oct 15 2010, 1:26 pm
From: LJHarb <jor...@brightkite.com>
Date: Fri, 15 Oct 2010 10:26:49 -0700 (PDT)
Local: Fri, Oct 15 2010 1:26 pm
Subject: Re: Problem with Post calls
I can attest that the OAuth processes are working, and that the API is
working - if you wish to verify for testing purposes, try just
explicitly authenticating (meaning, don't use OAuth, just include
`username` and `password` parameters.

If that call works, then the problem is in your OAuth library and
implementation. It looks like you're using http://code.google.com/p/oauth-signpost/
- I notice the example code differs from your example:

        // create an HTTP request to a protected resource
        URL url = new URL("http://api.example.com/protected")
        HttpURLConnection request = (HttpURLConnection)
url.openConnection();

        // sign the request (consumer is a Signpost
DefaultOAuthConsumer)
        consumer.sign(request);

        // send the request
        request.connect();

Specifically, the example says to use request.connect, while your code
uses httpClient.execute(request). Perhaps this is the issue?

- Jordan

On Oct 12, 9:50 pm, Codomaniac <mauze_muaw...@hotmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 18 2010, 12:54 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Sun, 17 Oct 2010 21:54:33 -0700 (PDT)
Local: Mon, Oct 18 2010 12:54 am
Subject: Re: Problem with Post calls
Now, as I did what u told me (following is the code for it)

  URL url=new URL("http://brightkite.com/objects/
aa6f52d903ec8407417238a609314a2b/comments.xml");
       HttpURLConnection conn = (HttpURLConnection)
url.openConnection();

       conn.setRequestProperty("comment[comment]", "xyz comment");

       conn.setRequestMethod("POST");
       conn.setRequestProperty("Content-Length",
String,valueOf(conn.getContentLength()));

     //Brighkiteproperties is my custom bean and it has the tokens etc
     DefaultOAuthConsumer consumer=new
DefaultOAuthConsumer(brightKiteProperties.getConsumerKey(),brightKiteProper ties.getConsumerSecret());

consumer.setTokenWithSecret(brightKiteProperties.getAccessToken(),
brightKiteProperties.getToken_secret());
     consumer.sign(conn);
     InputStream is= conn.getInputStream();

     for (int i = is.read(); i > -1; i = is.read()) {
       System.out.write(i);
         }

I have received in response !

java.lang.IllegalStateException: Already connected
        at
sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnect...
2235)
        at test.classes.testClass.URLStyle(testClass.java:300)
        at test.classes.testClass.main(testClass.java:249)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 19 2010, 7:43 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Tue, 19 Oct 2010 04:43:13 -0700 (PDT)
Local: Tues, Oct 19 2010 7:43 am
Subject: Re: Problem with Post calls
I missed one line

//placed after signing
conn.connect();

and the error is the same !


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LJHarb  
View profile  
 More options Oct 19 2010, 1:36 pm
From: LJHarb <jor...@brightkite.com>
Date: Tue, 19 Oct 2010 10:36:07 -0700 (PDT)
Local: Tues, Oct 19 2010 1:36 pm
Subject: Re: Problem with Post calls
At this point, I think the issues are in your code/library and not
with our API, so this group is no longer the best place to discuss it.
However, I'm still more than welcome to help you work through it -
please email me directly at < jor...@brightkite.com >.

If it turns out there's any issue with the API, or if we come up with
useful information for other API developers, I'll post it here so it
can help others.

- Jordan

On Oct 19, 4:43 am, Codomaniac <mauze_muaw...@hotmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 20 2010, 7:00 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Wed, 20 Oct 2010 04:00:00 -0700 (PDT)
Subject: Re: Problem with Post calls
It works now, but sadly i used (unwillingly :D) my Username and
password. Now I am trying to do it with OAuth, in the mean time any
help would be nice !

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

            HttpClient client = new HttpClient();
            BufferedReader br = null;

            PostMethod method = new PostMethod("http://brightkite.com/objects/
aa6f52d903ec8407417238a609314a2b/comments.xml");

            method.setParameter("comment[comment]","This works!");

            final String auth ="username:password";
            method.setRequestHeader("Authorization","Basic "+
Base64.encodeBytes(auth.getBytes()).trim());

            try{

              int returnCode = client.executeMethod(method);

              if(returnCode == HttpStatus.SC_NOT_IMPLEMENTED) {
                System.err.println("The Post method is not implemented by
this URI");
                // still consume the response body
                method.getResponseBodyAsString();
              } else {
                br = new BufferedReader(new
InputStreamReader(method.getResponseBodyAsStream()));
                String readLine;
                while(((readLine = br.readLine()) != null)) {
                  System.err.println(readLine);
              }
              }
            } catch (Exception e) {
              System.err.println(e);
            } finally {
              method.releaseConnection();
              if(br != null) try { br.close(); } catch (Exception fe) {}
            }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 22 2010, 2:00 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Thu, 21 Oct 2010 23:00:02 -0700 (PDT)
Local: Fri, Oct 22 2010 2:00 am
Subject: Re: Problem with Post calls

which OAuth do i use for this ? I know two implementations,
CommonsHttpOAuthConsumer and DefaultOAuthConsumer. However, I can't
seem to find any class that signs a POSTMETHOD object ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Codomaniac  
View profile  
 More options Oct 25 2010, 9:16 am
From: Codomaniac <mauze_muaw...@hotmail.com>
Date: Mon, 25 Oct 2010 06:16:13 -0700 (PDT)
Local: Mon, Oct 25 2010 9:16 am
Subject: Re: Problem with Post calls
http://support.brightkite.com/discussions/problems/88-oauth-doesnt-work

here is something similar to what I am asking !!!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
LJHarb  
View profile  
 More options Oct 25 2010, 6:52 pm
From: LJHarb <jor...@brightkite.com>
Date: Mon, 25 Oct 2010 15:52:26 -0700 (PDT)
Local: Mon, Oct 25 2010 6:52 pm
Subject: Re: Problem with Post calls
Unfortunately I'm not a Java developer, so all I can do is Google to
see if I can help.

http://developer.linkedin.com/thread/1442 seems similar to your issue.

Please email me directly at jor...@brightkite.com for further
discussion on this topic. If the API functions, and the problem is in
your implementation - although I will be happy to help you via email -
the Google Group is not an appropriate place for figuring out client-
side implementation issues.

Thanks!

- Jordan

On Oct 25, 6:16 am, Codomaniac <mauze_muaw...@hotmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »