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

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');

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.

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

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 "{

Okta application just redirect to a url

One of our requirements Is provision an app to an Okta user so he can click the app box and just redirect to an url with some query string parameters, no login required, is this possible using Okta?
You can add a Bookmark Application using the Apps API:
curl -v -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{
"name": "bookmark",
"label": "Custom Bookmark App",
"signOnMode": "BOOKMARK",
"settings": {
"app": {
"requestIntegration": false,
"url": "https://example.com/bookmark.htm?your=query&params=stuff"
}
}
}' "https://${org}.okta.com/api/v1/apps"
Then assign that app to a user:
curl -v -X PUT \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: SSWS ${api_token}" \
-d '{}' "https://${org}.okta.com/api/v1/apps/:appId/users/:userId"
To add on to kevlened's accepted answer, you can add a bookmark app through the Admin UI by going to Applications >> Applications >> Add Application >> search for "bookmark" from the application templates and you'll get the option to add a Bookmark App. This works in Version 2018.07 and perhaps earlier.

Can a pointer field, to "user" class, be updated via rest api?

I have a class A that has a pointer (pointer field) to the special class User. Is it possible to automatically update the pointer field with the authenticated user, using the Rest API instead of having to call the API like the example bellow?
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "X-Parse-Session-Token: ${SESSION_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"user":{ "__type": "Pointer", "className": "_User", "objectId": "${id}"}}' \
https://api.parse.com/1/classes/A
I would like to update the User field by just using the call:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "X-Parse-Session-Token: ${SESSION_TOKEN}" \
-H "Content-Type: application/json" \
https://api.parse.com/1/classes/A
And an A entry would be created.
A : {Pointer<_User> user_from_session, string objectId}
Any enlightenment is appreciated.
Cheers.
I've managed to accomplish what I wanted by adding an afterSave trigger. When creating A, with an authenticated request, I will read the current user from the session and set the field in the class. Bellow the example.
Parse.Cloud.afterSave("A", function (request, response) {
var record = request.object;
var user = Parse.User.current();
if (record.existed() == false) {
record.set("user", user);
record.save().
then(function (record) {
response.success();
}, function (error) {
response.error();
});
} else {
console.log("[DEBUG] Normal save (A).");
response.success();
}
});
Cheers.

Resources