How to change 'Content-Type: image/jpeg' using curl command in restapi? - shell

Any one help me how to change 'Content-Type: image/jpeg' format.
header='-H "Content-Type: application/json" -H "Authorization: Bearer '$token'" -H "x-api-key: '$key'"'
data='-d "{"image": "https://example.com/demo/img/hd-001.jpg"}"'
URL=https://variant.example.com/api/vi
i want to change content type to image/jpeg format.
i am getting bellow error.
{
"invalid_body",
body."
}
400: syntax error: operand expected (error token is "{

Related

Spring Boot and Spring Security Keyclock Integration - Error: connect ECONNREFUSED ::1:8180

I am doing Spring Cloud microservices development using link here - https://www.youtube.com/watch?v=LaZGedpfAyM&t=1279s and I was able to successfully make the GET request but for POST request I am getting the below error.
Source Code link - https://github.com/SaiUpadhyayula/springboot-microservices-project
I am not able to investigate as it seems as it seems issue at Keyclock?
CURL request -
curl --location --request POST 'http://127.0.0.1:8080/api/order' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJwYkNvVGtKOE0tZmZLaXJ0OXRVRjFNSlFxVUJlaXA3YlJFVzY3akpBMmEwIn0.eyJleHAiOjE2MTg3NDk4MzUsImlhdCI6MTYxODc0OTUzNSwiYXV0aF90aW1lIjoxNjE4NzQ5Mzc3LCJqdGkiOiJmZDZmYmEwZC1kMjg5LTRjMDEtYTc5MS02NTU1MGJiOTJmOWIiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgxODAvYXV0aC9yZWFsbXMvbWljcm9zZXJ2aWNlcy1yZWFsbSIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiIzZGU0YmY1NC0xYjUxLTQwZDMtYTEzOC1iMTVlMDJiMzVjNTgiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJzcHJpbmctY2xvdWQtZ2F0ZXdheS1jbGllbnQiLCJzZXNzaW9uX3N0YXRlIjoiZTIzMGNkYzgtNDVhNi00YmE4LWJlMjMtMTkwNTEwMWQ1MzcyIiwiYWNyIjoiMCIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwibmFtZSI6InRlc3QgdXNlciIsInByZWZlcnJlZF91c2VybmFtZSI6InRlc3R1c2VyIiwiZ2l2ZW5fbmFtZSI6InRlc3QiLCJmYW1pbHlfbmFtZSI6InVzZXIiLCJlbWFpbCI6InRlc3R1c2VyQGdtYWlsLmNvbSJ9.DOeBxnCkL2jUuK_waq5JtOS-a3AD1y3C_hhirpA7lOU8xpgUujsXpjz3o53TJCAHHlxzC42wQ5oeFi6YXiSuuBRP9vpL6ePWYF3PtD2dgpZdkt5QT0BQiSjStGMY7xb4O8sd3BdRL_RkCpRx0GiV_rE4qZcQBHqdkarozOoq23GmbFD0XT5C119EUVjwn2ZirmPzFWYODJp6H5ExDEV1xm6cdZXBJZGSM4tINNaZheV9AkkpFpySt_CD74Hbj0KwbjJMCSGB5hNA0ZLEozjV14FinJrEUlcW8hBogY2Rd-XPqb0lwAlkqdLQKqu0AMWZrl0AoM7YaasZHvB7uZHG2Q' \
--header 'Cookie: SESSION=9328910f-b82e-4fc9-9019-8ae9259aef8e' \
--data-raw '{
"orderLineItemsList" : [
{
"skuCode" : "iPhone 12",
"price": 1230,
"quantity" : 1
}
]
}'

Graph API List Channel Messages Returnng UnknownError after Protected API Request Approved

I am unable to get a good response, and having hard time finding Docs. Can't find a way to lookup the inner error code at all either. I get a token using
curl -L -X POST 'https://login.microsoftonline.com/51bcb6e4-b738-4e87-a795-768e3f13b94f/oauth2/v2.0/token' \ -H 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id=5bbd5786-31d3-4d84-a8d0-a0dac6522f93' \ --data-urlencode 'scope=https://graph.microsoft.com/.default' \ --data-urlencode 'client_secret=<secret>' \ --data-urlencode 'grant_type=client_credentials'
and then take the access_token value, and do this
curl -L -X GET 'https://graph.microsoft.com/v1.0/teams/d89133ea-bf32-4957-8300-aa5e083f45c1/channels/19:5b075a993aee4b3fa8f23be2cbb3b514#thread.skype/messages' \ -H 'Authorization: Bearer <token value from above>'
But I get this error 403:
{ "error": { "code": "UnknownError", "message": "", "innerError": { "date": "2021-03-09T19:15:23", "request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77", "client-request-id": "c9a8cf3a-b914-44a8-a66a-506634f09d77" } } }
how can I troubleshoot? the url for the GET seems right, based on all my research. we are using resource specific consent permissions, but the app is installed in the channel that I am trying to list messages. from
This question will be tracked from here.

Error on add a teacher to a classroom - Failed Precondition

I've had problems to add teachers to a classroom. The problem happens in specific classrooms and I received a Precondition Error Message.
Request:
curl --request POST \
'https://classroom.googleapis.com/v1/courses/11115612909/teachers' \
--header 'Authorization: Bearer [YOUR_BEARER_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"userId":"ana.gomes#***"}' \
--compressed
Response:
{
"error": {
"code": 400,
"message": "Precondition check failed.",
"status": "FAILED_PRECONDITION"
}
}
I've already checked all the conditions described in the api reference, but everything is correct (quotas, group numbers, classroom numbers).

How do I map the JSON body of a GET request to a parameter?

I have the following definition in my endpoint:
params do
requires :entities do
requires :id, type: String
optional :email, type: String
optional :phone, type: String
end
end
post "test" do
end
Note this only works as a POST request and the following CURL will work:
curl -XPOST localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'
However, the moment I change the declaration to get "test" instead of post, the corresponding curl request with -XGET no longer works due to the following validation error:
{"error":"entities is missing"}
If I remove the params requirements I can manually inspect the params hash at runtime and see that it only has a single key "route_info"
I'm currently using Grape 0.7.0
It happens because by specifying -d option you pass parameters in the body of the request while your endpoint is expecting them in the path as part of the url. Check here why it's a bad idea to pass body parameters in a GET request.
However, can use that option but if combination with -G.
-G, --get
When used, this option will make all data specified with -d, --data, --data-binary or --data-urlencode to be used in an HTTP GET request
instead of the POST request that otherwise would be used. The data will be appended to the URL with a '?' separator.
So that your get request by using -d would look like:
curl -XGET -G localhost/test
-H 'Content-Type: application/json'
-H 'Accept: application/json'
-d '{ "entities": [{ "id": 3, "email": "test#abc.com" }] }'

Input::all() is not working - laravel 4

I'm new to Laravel, tried posting data using the following cURL command but when I try to read data, it wouldn't do it.
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":100}' api.xyz.com/test
There's a solution here* using file_get_contents but I'm sure there must be a better way:
Laravel - POST data is null when using external request
I ran the following curl command
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"John", "surname":"Doe"}' http://localhost/laravel/public/test
and returned a json_encode(Input::all()) in my HomeController#test and got the following output
{"name":"John","surname":"Doe"}
HomeController.php
public function test()
{
return json_encode(Input::all());
}
routes.php
Route::post('/test', 'HomeController#test');

Resources