hash passes as a string?


Tim Fong <timfong888@...>
 

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls
HTTP/1.1


Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph

would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?

For http auth, can I use in the third (header) {:user => , :password =>}?

Thanks.


Archiloque <code@...>
 

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls
HTTP/1.1


Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph

would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?

For http auth, can I use in the third (header) {:user => , :password =>}?

Thanks.

user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)

or you can use the execute method and pass them as parameter

RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')

Does this answer your question ?

A.


Tim Fong <timfong888@...>
 

Hi, thanks, okay, that's what I was using but wondered if there was support for http auth without the URL.

How about posting the caller info? The format looks like a string, but do I create a hash key-value pair as I described below?

thanks!

On Sun, 13 Jun 2010, Archiloque wrote:

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)

or you can use the execute method and pass them as parameter

RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')

Does this answer your question ?

A.


Tim Fong <timfong888@...>
 

How does restclient automatically parse XML responses so i can access them as attributes?

On Sun, 13 Jun 2010, Archiloque wrote:

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)

or you can use the execute method and pass them as parameter

RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')

Does this answer your question ?

A.


Archiloque <code@...>
 

Le 13 juin 2010 à 17:47, Tim Fong a écrit :

Hi, thanks, okay, that's what I was using but wondered if there was support for http auth without the URL.

How about posting the caller info? The format looks like a string, but do I create a hash key-value pair as I described below?

thanks!
normally the hash should work, see my example




On Sun, 13 Jun 2010, Archiloque wrote:

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)

or you can use the execute method and pass them as parameter

RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')

Does this answer your question ?

A.


Archiloque <code@...>
 

Le 13 juin 2010 à 18:35, Tim Fong a écrit :

How does restclient automatically parse XML responses so i can access them as attributes?
restclient doesn't automatically parse xml responses so you have to do it yourself, where do you find this information ?


On Sun, 13 Jun 2010, Archiloque wrote:

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)

or you can use the execute method and pass them as parameter

RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')

Does this answer your question ?

A.


Tim Fong <timfong888@...>
 

Hi, thanks, I saw the answer, would it work with:

response = RestClient.post url,{'Caller' => '65055555'} ?

Or what if it were:

resp = RestClient.post url, body

where body = Caller=xxxx&Called=xxxxx&URL=http://www.something.com

I have tried using the body approach and I get a bad request.

On Sun, 13 Jun 2010, Archiloque wrote:


Le 13 juin 2010 à 17:47, Tim Fong a écrit :

Hi, thanks, okay, that's what I was using but wondered if there was support for http auth without the URL.
How about posting the caller info? The format looks like a string, but do I create a hash key-value pair as I described below?
thanks!
normally the hash should work, see my example

On Sun, 13 Jun 2010, Archiloque wrote:

Le 13 juin 2010 à 07:12, Tim Fong a écrit :

Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)
or you can use the execute method and pass them as parameter
RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')
Does this answer your question ?
A.


Archiloque <code@...>
 

Le 13 juin 2010 à 19:09, Tim Fong a écrit :

Hi, thanks, I saw the answer, would it work with:

response = RestClient.post url,{'Caller' => '65055555'} ?

Or what if it were:

resp = RestClient.post url, body

where body = Caller=xxxx&Called=xxxxx&URL=http://www.something.com

I have tried using the body approach and I get a bad request.
it should work as there is special case to manage string payload, perhaps an escaping problem in your payload ?

A.


On Sun, 13 Jun 2010, Archiloque wrote:


Le 13 juin 2010 à 17:47, Tim Fong a écrit :

Hi, thanks, okay, that's what I was using but wondered if there was support for http auth without the URL.
How about posting the caller info? The format looks like a string, but do I create a hash key-value pair as I described below?
thanks!
normally the hash should work, see my example

On Sun, 13 Jun 2010, Archiloque wrote:
Le 13 juin 2010 à 07:12, Tim Fong a écrit :
Hi, wasn't sure how to POST the following using rest-client:

POST /2008-08-01/Accounts/AC309475e5fede1b49e100272a8640f438/Calls HTTP/1.1
Caller=4158675309&Called=4155551212&Url=http://www.myapp.com/myhandler.ph
would I pass {:caller => '415....', :called => '415555'} or do
I make a string 'Caller=415...' and make it equal payload and
just make that the second attribute?
For http auth, can I use in the third (header) {:user => , :password =>}?
Thanks.
user and password you can't use the header form: you can either put them in the url (https://user:password@example.com/private/resource)
or you can use the execute method and pass them as parameter
RestClient::Request.execute(:method => :post,
:url => 'http://rmoerzemzeg.com',
:payload => {'a' => 'amihe',
'azugeaz' => 'async'},
:user => 'blah',
:password => 'blah')
Does this answer your question ?
A.