How to prevent insert of data that is passed using query string in sails.js for post request? - sails.js

I have created new table in mysql also created model and controller in sails.js. Now I am trying to insert data using sails. As we know when we create new modal in sails it will create new post, get and other api for us by default.
Now I am trying to insert data using post api using query string and request.body and both are working But I need to insert data into db that is passed using request.body instead of request.querystring data in post request.
How can I do it???
Post data using query string in post request => working fine
Post data using request.body in post request => working fine (I want to insert data using this way only)
Same question I asked here https://gitter.im/balderdashy/sails and https://github.com/balderdashy/sails/issues/6918

sails uses Waterline, this performs sanitation by itself, you should be fine whenever you are using some of this built-in model methods:
.find()
.findOne()
.updateOne()
.archiveOne()
.destroyOne()
.create()
.createEach()
.count()
.sum()
.avg()
.addToCollection()
.removeFromCollection()
As an extra layer of security you can check that the providing data types are correct and verify range, characters, etc. There are also policies which allow you to restrict certain actions to logged-in users only.
hope this was helpful :)

When you create an API by command line, you'll get an API that lets you search, paginate, sort, filter, create, destroy, update, and associate. Since these blueprint actions are built-in Sails. You can override these actions by yourself.
Find more at in Sails.js Documentation

Related

NestJs #ResolveField alternative in REST

In NestJs when we use it in combination with GraphQl, we can call #ResolveField decorator, do we have some alternatives when we use REST?
I have worked once with GraphQl and used that decorator, and now im working with rest, and want to know do we have something simillar in NestJs without Graph.
REST does not have the idea of being able to optionally add extra fields to the response just by adding a sub field to the response. It's not a query language like GraphQL is. You would need to either add in a query parameter that allows the client to say "fetch extra data" or just return the extra data by default and let the client ignore it if it is not wanted

DocuSign API: Is it possible to filter envelopes by the value a document field?

Assuming I have a field with label FOO in all the envelopes sent, how do I filter the envelopes where the value of FOO is 123456?
I tried setting the search_text parameter with 123456 but it doesn't work.
This is the request I tried to use:
https://demo.docusign.net/restapi/v2.1/accounts/reste_idreste/envelopes?from_date=2021-02-01&search_text=123456
Unfortunately, there's not currently a way to search Tabs/Form Data via the API. We do have long term plans in this area, but nothing firm yet. I would pass this request along to your account team to let them know you are interested in learning more about that functionality as it develops.
The ListStatusChanges call doesn't allow you to pull form data in bulk. You'd need to make one GetEnvelope call per envelope with include=recipients,tabs to pull form data and parse through it yourself.
If this is something you are looking at building out, you could use populate a local database using the GetEnvelope results, and then use DocuSign Connect to automatically pass information about new envelopes moving forward.
It is possible to search for values of Envelope Custom Fields. Moving forward, if your application can populate an ECF, you can then search for that to find specific envelopes.

Routing incoming request

I am trying to create a simple API using Go that performs certain operations depending on the data provided.
I was planning to provide JSON data to this API and get details from it for further use.
Since I was trying to provide JSON data I created the routing using gorilla/mux as below:
router.HandleFunc("/msa/dom/perform-factory-reset?json={jsonData}", CallGet)
log.Fatal(http.ListenAndServe(":8080", router))
But while trying to hit the endpoint http://localhost:8080/msa/dom/perform-factory-reset?json={"vrf":"ds","ip":"45","mac":"452","method":"gfd"} I am getting 404 page not found error.
Hence I tried to change the implementation such that new routing is done as:
router.HandleFunc("/msa/dom/perform-factory-reset/json={jsonData}", CallGet)
This works absolutely fine and I am able to perform desired tasks. Could someone tell me why this is happening?
Is the router gorilla/mux? If so, you cannot add query parameters to path like that. You have to:
router.Path("/msa/dom/perform-factory-reset").
Queries("json","{jsonData}").HandlerFunc(CallGet)
If it is some other router, then you still probably have to register path without the query parameters, and then get the query parameter values in the handler from the request.

How to get a list of all documents in a Firebase Cloud Firestore database using the API?

I need to query my Cloud Firestore database periodically for maintenance. I'm new to REST and I've spent way too long trying to solve this myself, so I figured I could use some advice.
My Firestore is set up like so:
users > {uid} > uploaded-files > {file-hash}
{file-hash} is a document that contains several fields such as filename, source, and size
All I'm trying to do is get a list of every single filename from every single uploaded-file, including from multiple {uid}'s.
I've managed to send a successful request and get a single filename using the firestore.projects.databases.documents.get method using the API explorer, but I can't seem to get any other methods to work, namely firestore.projects.databases.documents.list
This is the successful request using firestore.projects.databases.documents.get:
GET https://firestore.googleapis.com/v1beta1/projects/{project-id}/databases/(default)/documents/users/7eGfdgGfaG0HSXdfmxMN2/uploaded-files/WGtcJBX9fdGdhdtjB?mask.fieldPaths=filename&key={YOUR_API_KEY}
Part of my issue is that I can't figure out how to get requests to work without hard-linking document names - in other words, I don't know how to to replace {uid}, or any other collection, with a wild-card so that the request returns documents from all uid's.
Really any help is greatly appreciated.
The Use the Cloud Firestore REST API documentation has instructions on getting started. The Firestore REST API documentation shows how to fetch documents.
In your case you would need to list the user-uid documents then go after the uploaded-files for each one, or iterate over the results of the list.

What URL should be used to create/Modify OIM user via REST API SCIM for UDF?

I am trying to create and modify users using SCIM/REST API's available OOTB in 11gR2PS3.
I am able to create/modify users for all the OOTB attributes specfied in the document
As per the documentation, these API's are supported for custom UDFs as well.
Does anyone know what the schema attributes name and format that needs to be passed in the content body for custom UDF's?
As per the documentation
Note: You can use user defined fields (UDFs) in SCIM requests. After
UDFs are created in Oracle Identity Manager, they automatically appear
in SCIM resources as regular attributes. There is no difference in the
requests and responses with regular attributes.
when we crate the user even after specifying the UDF value its not going in OIM DB and it also doesn't throw any exception.
call /Schemasoperation using get method
using your OIM URL :http://<host>:<port>/idaas/im/scim/v1/Schemas
Use the returned schema while using create, update operation on the UDF.
e.g. schema returned is urn:ietf:params:scim:schemas:extension:oracle:2.0:OIG:User
then qualify UDF with the returned schema while calling Create/Update operation.
"urn:ietf:params:scim:schemas:extension:oracle:2.0:OIG:User":{
UDFNAME : UDFVALUE
}
also incluede the schema in the schemas[] if its not there already.