Push data using routes in laravel - laravel

I'm trying to have an api which stores the information into my CRM, to push the details I've following parameters/details to store into the data:
Called_number, caller_number, agent_number, date, time, call_status, total_call_duration, Call_UUID, Recording_URL, conversation_duration
I've created the migration table with the same data name mentioned above, request protocol is HTTP, request data type is Query String and response data type is JSON.
Data is being sent by simple URL from third party so I'm using simple post route to insert the data into the database like this:
Route::post('/calllogs/{called_number}/{caller_number}/{agent_number}/{date}/{time}/{call_status}/{total_call_duration}/{call_UUID}/{recording_URL}/{converstation_duration}', 'CalllogController#insert')
Is there any way to secure this with some dynamic API keys to prevent inserting fake data? I mean any person having idea of the URL, can make the url and will insert data into my database, I want to have something like this:
Route::post('/calllogs/{api_key}/{caller_number}....
where I can check the api_key dynamically and then insert into the database.
Thanks.

This library (API Guard) is probably what you're looking for, it does exactly what you want: securing API calls with authorization keys.

Related

Rest API Call in uipath

My requirement is to fetch the data from rest api data and store it in separate variable. I had the endpoint url(https://abcdev.service-now.com/api/now/table/sc_multi_row_question_answer?sysparm_query=parent_id%3Dxxxxxxxxxxxxxxxxxxxx&sysparm_display_value=true&sysparm_exclude_reference_link=true&sysparm_fields=variable_set%2Cvalue%2Citem_option_new%2Crow_index).This is fetching the datas for all 3 rows. But i wants that this user needs to be added in this delegate access like that.
I have attached the image for which field i want to fetch.
I wants to fetch user to be added,level of access required,inbox,calender,tasks,contacts,notes,journal,select required send rights for these field i wants to fetch row by row.kindly assist me in that.
You will receive the response in JSON with all the rows, but you can use de serialize JSON Array activity to de serialize the JSON in each record with all the columns you have mentioned.
And Once you have the rows in the array JSON you can loop through it and get the details for each field.

How to fetch the variable value in service now when ordering item from service catalog?

I have successfully ordered an item from service catalog using REST API. While ordering I sent a JSON data in the request body containing certain key value pairs which are meant to be stored in variable of the catalog item. After the successful order, the response generated contains the sys_id, request_number, request_id, table name. Now, when I want to fetch the values passed to variables, the only way available is to make a GET call using the REST API for Tables. So, I am fetching the record using the generated sys_id and table name which is generated as response of order API. The table name is sc_request.
But that is not providing the variable value information in the response body of the GET call.
You should be able to get the values of variables using the Table API. If you go to the REST API explorer in ServiceNow, notice the field "sysparm_fields". put the name of your variabe(s) in there like this "variables.var_name". This will retrieve their values and display values in the response.

How to save json feed to MongoDB in Laravel and get the key?

I need the following: I make GET requests to the API and receive responses in JSON format.
We have some sort of logs about responses and I'd like to keep record about the content of these JSON objects on the moment of the request.
In the Laravel command, I have to:
1) Save JSON object to MongoDB and get the unique key "feed_id" from collection under which it was saved.
2) Save the "feed_id" to the table column, where we store logs about history of requests.
How can I implement the first step in Laravel? I have seen some example, but without getting the id.
there is a excellent package for mongoDB in laravel named jenssegers/mongodb
you can install it via composer.
once you've installed it , you can simply insert an object and get the id in response like you do with eloquent and mysql

GraphQL pre-approved queries

I read that Facebook's internal servers accept any queries in dev
mode, and these are cached. In production, only a pre-approved/cached
query is permitted. This was mentioned as a model which other servers
should adopt.
Does someone know what tools do they use for that? Does this process is described more detailed somewhere?
I don't know how it's down in facebook but I can explain how I did it in GraphQL Guru. As graphql is language agnostic I'll explain without being language specific.
The way persisted queries work is a client sends a query with a unique id and variables to a graphql (persisted query ready) server.
{
"id": "1234",
"varibles": {
"firtName": "John",
"lstName": "Smith"
}
}
For the id don't use a hash of the query as the this results in long id names of varying sizes, which kind of defeats the purpose.
On your server, create a file with the same name as the persisted query id, which contains the actual graphql query. Or save it in a database.
To get the graphql query you will need to intercept it via middleware. The middleware retrieves the graphql query via its id and passes the query on to the graphql endpoint. Depending on how the query was defined the middleware may need to parse it. Also, it is in the middleware where you can whitelist if the persisted query id does not exist.
Then the graphql endpoint process the query as normal.
You can see a nodejs example here https://github.com/otissv/guru-express-server/blob/master/src/routes/graphql-route.js

WebAPI - odata service adding ForeignKey

i am building my the model using ODataModelBuilder, i am trying to create navigation property however in the metadata i dont see any foreginkey indication, in my solution i am not using EF, so there is no foreignKey attribute, is it possible to add it by code?
As you clarified in your comment, the reason you want to add foreign key information is because your client application is not including related entities when you query the main entity. I don't think foreign keys are the problem here.
As an example, I'll use two entity types: Customer and Order. Every Customer has some number of associated Orders, so I have a navigation property on Customer called Orders that points to a collection of Orders. If I issue a GET request to /MyService.svc/Customers(1), the server will respond with all of the Customer's information as well as URLs that point to the related Order entities*. I won't, by default, get the data of each related Order within the same payload.
If you want a request to Customers(1) to include all of the data of its associated Orders, you would add the $expand query option to the request URI: /MyService.svc/Customers(1)?$expand=Orders. Using the WCF Data Services client (DataServiceContext), you can do this with .Expand():
DataServiceQuery<Customer> query = context.Customers.Expand("Orders");
However, WebAPI OData doesn't currently support $expand (the latest nightly builds do though, so this will change soon).
The other approach would be to make a separate request to fill in the missing Order data. You can use the LoadProperty() method to do this:
context.LoadProperty(customer, "Orders");
The LoadProperty approach should work with WebAPI as it stands today.
I know this doesn't answer your original question, but I hope addresses your intent.
*In JSON, which is the default format for WebAPI OData services, no links will show up on the wire, but they are still there "in spirit". The client is expected to be able to compute them on its own, which the WCF Data Services Client does.

Resources