A
A
A_Modestov2016-07-19 19:18:00
Ruby on Rails
A_Modestov, 2016-07-19 19:18:00

How to correctly form a POST request through curl?

Good afternoon, ladies and gentlemen. Such a task: to check, you need to form a request in curl POST for the controller's create method.
The method accepts parameters:

params.require(:facebook_token).permit(:url, :login, :password, :proxies)

The following query almost accomplishes the task:
curl -d "facebook_token[url]=https:\//www.facebook.com\/dialog\/oauth?client_id=123456&redirec_uri=blablabla" -d "facebook_token[login][email protected]" -d "facebook_token[password]=54321" -d "facebook_token[proxies]=asdfghj"  http://localhost:3000/facebook_tokens.json

But the part of the facebook_token[url] parameter is cut off
&redirec_uri=blablabla

, i.e. the parameter gets
https:\//www.facebook.com\/dialog\/oauth?client_id=123456
.
How to fix it? Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shvaikin, 2016-07-19
@A_Modestov

Two strings can be passed to curl with the d key:
respectively, your string

"facebook_token[url]=https:\//www.facebook.com\/dialog\/oauth?client_id=123456&redirec_uri=blablabla"
parsed into two parameters ( facebook_token[url]and redirec_uri)
Try escaping the ampersand or split it into two parameters facebook_token[url]and facebook_token[client_id].

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question