Do your query parameters from the initial GET get cleared from the request
before the POST? If you're not sure send the client #resetEntity.


Is the response of the GET correct & are the keys decoded properly? if not
can you get a valid signature and request key from somewhere else (e.g. web
ui, or ....) to test the POST?


Is it important to reuse the connection?  IF not add the #beOneShot method
to both and see if that helps as it does some resetting.  

The #post method is a convenience method that conjoins a send to #method:
and #execute.  You could separate them and use #method: at the top and
#execute; before the #request line but I'd be surprised to learn that fixed
things.


Good luck

Paul






Tim Mackinnon wrote
> Hi I'm a bit confused about how to send a get request to a resource and
> then post a response to it? I seem to fail on the post part, as it seems
> that my query is not being well formeed - or something is not being
> cleared when I reuse the connection I used in the get.  My code looks as
> follows (and I'm sure there is a simple mistake).
> 
> It seems that in my post request, it doesn't formulate the post I expect -
> it shows a GET / msg, and as such my response doesn't give me the token I
> expect.  If I move the "post" line up to the start, I seem to get a
> request header I expect, but still not the the result I expect. Can anyone
> offer any tips? Do I need to clear my Client in some way before the second
> post operation?
> 
> Tim
> 
> | znc resp |
> 
> (znc := ZnClient new) logToTranscript.
> 
> resp := znc
>       url: 'https://trello.com/1/authorize';
>       queryAt: 'scope' put: 'read';
>       queryAt: 'expiration' put: '1day';
>       queryAt: 'name' put: 'Pharo App';
>       "queryAt: 'response_type' put: 'token';"
>       queryAt: 'key' put: 'xxxxxx1d588819825d57da6dad4dd';
>       get;
>       request;
>       response.
>       
> soup := (Soup fromString:  resp entity).
> sig := soup findTag: [ :e | (e name = 'input') and: [  (e attributeAt:
> 'name' ifAbsent: ['']) = 'signature' ]].
> key := soup findTag: [ :e | (e name = 'input') and: [  (e attributeAt:
> 'name' ifAbsent: ['']) = 'requestKey' ]].
> 
> resp := znc 
>       url: 'https://trello.com/1/token/approve';
>       formAt: 'approve' put: 'Allow';
>       formAt: 'requestKey' put: (key attributeAt: 'value');
>       formAt: 'signature' put: (sig attributeAt: 'value');
>       post;
>       request;
>       response.





--
View this message in context: 
http://forum.world.st/ZnClient-get-then-post-tp4764605p4764608.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to