curl -X PUT
-H "Content-Type: application/json"
-d
'{ “Owner”: { "id" : "root" } }'
-H 'Authorization: token XXX_Token_XXX'
'http://XXX_RT_URL_XXX/REST/2.0/ticket/6'
This command works for updating values of a ticket at the top level of JSON, but values such as 'Owner' fails. The documentation does not denote any method as to update these specific fields. What is the recommended way to update a ticket's Owner field via the Request Tracker REST API 2.0 (rt-extension-rest2)?
Try with the username as the value:
curl -X PUT
-H "Content-Type: application/json"
-d
'{ “Owner”: "root" }'
-H 'Authorization: token XXX_Token_XXX'
'http://XXX_RT_URL_XXX/REST/2.0/ticket/6'
That should accept a username or user ID.
Related
I need to get "Get a 2-Legged Token" verification for a read-only access to upload files entered by other users but I'm running into the following error:
{
"developerMessage": "The required parameter(s) client_id,client_secret,grant_type not present in the request",
"errorCode": "AUTH-008",
"more info": "https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/"
}
I followed exactly the example on the site changing just my "client id" and my "client secret":
https://forge.autodesk.com/en/docs/oauth/v1/tutorials/get-2-legged-token/
can anybody help me?
The single quote is wrong format in header of curl.
Try this format
curl --location --request POST 'https://developer.api.autodesk.com/authentication/v1/authenticate' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=your_client_id_xxx' \
-d 'client_secret=your_client_secret_xxx' \
-d 'grant_type=client_credentials' \
-D 'scope=data:read'
It will be return access token
I am using Postman for HTTP call.
It is more convenient
When i used CURL post from console then its work but when i used linkedin gem method in controller then its not working and get error regarding access token. Where is wrong here not findout.
CURL Code
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"comment":"hello from google www.google.com! http://ibm.com","visibility":{"code":"anyone"}}' https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=AQVxxxxJXygzp_8Exxxxg7_7FaxxxxxxtWzBXAxxxxxa5z1MVK6-kubHJ5JIaGAxxxx234wndpAMc_CxmCsIHxxxxraleZqkU0t_WNEhxxxz8_cKpeOixxxxsd15-X-MdvzYVxxxx9hQ&format=json&title=linkedin HTTP/1.1
LinkedIn gem code
client = LinkedIn::Client.new(
config[:your_consumer_key],
config[:your_consumer_secret]
)
client.authorize_from_access(
config[:oauth_user_token],
config[:oauth_user_secret]
)
client.add_share(
comment: 'Good Morning',
content: {'submitted-url' => 'http://www.github.com/blazeeboy' }
)
Any one have a idea where is wrong here.
============= UPDATE =============
system 'curl -H "Content-Type: application/json" -H "authToken: auth_token" --data '{"comment":"hello from google www.google.com! http://google.com","visibility":{"code":"anyone"}}' https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=AQVxxxxygzp_8E3ySvg7_7FahixxxxxxtWzBXAja5OQ8a0wta5z1MVK6-kubHJ5JIxxxxwndpAMc_CxmCsIHxFlexxxxxleZqkU0t_WNxxxxmi7CMz8_cKpexxxx15-X-MdvzYVOxxxxm9hQ&format=json&title=linkedin HTTP/1.1'
Thanks
curl -H "Content-Type: application/json" -H "authToken: auth_token" --data '{}' https://api.linkedin.com/v1/people/~/shares
Try running this :
system "curl -H 'Content-Type: application/json' -H 'authToken: auth_token' --data '{'comment':'hello from google www.google.com! http://google.com','visibility':{'code':'anyone'}}' https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=AQVxxxxygzp_8E3ySvg7_7FahixxxxxxtWzBXAja5OQ8a0wta5z1MVK6-kubHJ5JIxxxxwndpAMc_CxmCsIHxFlexxxxxleZqkU0t_WNxxxxmi7CMz8_cKpexxxx15-X-MdvzYVOxxxxm9hQ&format=json&title=linkedin HTTP/1.1"
In rails when you use double quotes inside single quotes it gives error with some commands.
OR you can try like this :
`curl -H 'Content-Type: application/json' -H 'authToken: auth_token' --data '{'comment':'hello from google www.google.com! http://google.com','visibility':{'code':'anyone'}}' https://api.linkedin.com/v1/people/~/shares?oauth2_access_token=AQVxxxxygzp_8E3ySvg7_7FahixxxxxxtWzBXAja5OQ8a0wta5z1MVK6-kubHJ5JIxxxxwndpAMc_CxmCsIHxFlexxxxxleZqkU0t_WNxxxxmi7CMz8_cKpexxxx15-X-MdvzYVOxxxxm9hQ&format=json&title=linkedin HTTP/1.1`
I'm trying to test making a post request with cURL passing a file into nested params, but having a hard time getting the flags/ordering correct:
curl -i -H "Authorization: <access_str>" -H "Accept: application/json"
-H "Content-Type: application/json" -X POST -d '{"data": {"photo":
"#/Users/colin/Desktop/mastiff.jpg"} }' localhost:3000/api/v1/blah/blah
I feel like I either need a --data-binary or -F or both maybe? The server is just getting the nested params as a string and not as a multipart file
{"data"=>{"photo"=>"#/Users/colin/Desktop/mastiff.jpg"}
curl -i -H "Authorization: <access_str>" -X POST -F
'data[photo]=#/Users/colin/Desktop/mastiff.jpg'
localhost:3000/api/v1/data/data/data
Don't even need to specify that it's JSON. Next step is trying to pass two photos in the same field. The problem now is that passing a second file results in a massive binary string.
How can I authenticate my Ruby on Rails Application using cURL from terminal using Devise?
I'm trying:
curl --user email:password http://domain.bla/api/auth/sign_in
And is responding:
The page you were looking for doesn't exist.
This works for me :
curl -XPOST -v -H 'Content-Type: application/json' http://domain/api/v1/auth/sign_in -d '{"email": "email#domain.com", "password": "password" }
So I get back the response (something like below, only important part) :
< access-token: lW1c60hYkRwAinzUqgLfsQ
< token-type: Bearer
< client: W_xCQuggzNOVeCnNZbjKFw
< expiry: 1426610121
< uid: email#domain.com
Then I can validate the token, using the client and token previously obtained from the above request, I do it like this :
curl -XGET -v -H 'Content-Type: application/json' -H 'access-token: lW1c60hYkRwAinzUqgLfsQ' -H 'client: W_xCQuggzNOVeCnNZbjKFw' -H "uid: email#domain.com" http://domain/api/v1/auth/validate_token
The result :
{"success":true,"data":{"id":3,"provider":"email","uid":"email#domain.com","firstname":null,"lastname":null,"email":"email#domain.com"}}
I found that the login step needed to be wrapped in a user dictionary, viz:
curl -X POST -v -H 'Content-Type: application/json' \
http://somehost.com/users/sign_in -d \
'{"user" : {"email": "some_user#nowhereville.org", "password": "OpenSecret" }}'
This is Devise 3.5.4.
I'm sending json request via curl to my local web server
curl -H 'Content-Type: application/json' -d {"name":"Stanford University", "subdomain":"stanford"} http://localhost:3000/rest/v1/groups.json
But in my rails app in params i'm getting
Parameters: {"name"=>"Stanford University", "subdomain"=>"stanford", "group"=>{"name"=>"Stanford University", "subdomain"=>"stanford"}}
Where did that hash group came from, and how do i controll it?
Look in config/initializers/wrap_parameters.rb. You likely have wrap_parameters enabled for JSON requests.
You can disable this option in the above file with
wrap_parameters false
Recommended Reading: http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html
You have to send it into Json Format
Try Following
curl -H 'Content-Type: application/json' -d "{\"name\":\"Stanford University\", \"subdomain\":\"stanford\"}"
OR
hash = {"name":"Stanford University", "subdomain":"stanford"}
curl -H 'Content-Type: application/json' -d "#{hash.to_json}" http://localhost:3000/rest/v1/groups.json