REST query to get all roles for particular user from parse server - parse-server

How to create a REST query to get all roles assigned to a user?
As this is many to many relation in the opposite direction the regular $relatedTo operator seems to be not enough...

finally I found the solution which seems to be much easier than I was afraid of :) As I found similar questions on SO and github I hope it will help others.
the curl query to get all the roles directly assigned to a user is:
curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
https://parseapi.back4app.com/roles \
--data-urlencode \
'where={"users":{"__type":"Pointer","className":"_User","objectId":"<objectId>"}}'

Related

twitter api v2 to capture random sample of a specific language

I can't believe this is not a common/often considered query to the twitter v2 API
We are looking for a sample of tweets in a specific language (we're testing language translation tech) e.g. english or spanish.
There exists a sample end point, there exists a search query end point, however
sample endpoint doesn't seem to allow to attach a query. The search query doesn't seem to allow an 'empty search string', on which can add the language specifier
we've tried things like (as no real clues in the docs, so these do fail as expected)
curl --request GET 'https://api.twitter.com/2/tweets/sample/stream?lang:en'
curl --request GET 'https://api.twitter.com/2/tweets/search/recent?query=lang:en'
curl -X POST 'https://api.twitter.com/2/tweets/search/stream/rules' \
-H "Content-type: application/json" \
-H "Authorization: Bearer <TOKEN>" -d \
'{
"add": [
{"value": " lang:en"}
]
}'
and also things like
"'{
"add": [
{"value": "from: * lang:en"}
]
}'
we could query the sample, include the language field and then dismiss all we are not interested in, but given we need large volumes, this will waste quotas.
Anyone accomplished this?

Jira API not filtering on fields

I can't seem to get my request results to filter on the field pass. No matter what I input I get this massive data dump from Jira. Nor does it seem to limit by the maxResults count. Here's the API call:
curl -u app_jira_docs:"xxxxxxxxxx" --url 'https://jira.xxxxxxxxx.com/rest/api/2/search?jql=project=10506&"name"="epic"&"fields"="summary"&startAt=0&maxResults=2' -H "Content-Type: application/json" | jq '.' --sort-keys
Any help would be great.
I was able to get a similar query to filter correctly by swapping a few of your parameters around and adjusting some of the formatting:
curl --location --request GET 'https://jira-url/rest/api/latest/search?jql=project%3D10506%20AND%20name%3Depic&fields=summary&startAt=0&maxResults=2' --header 'Accept: application/json'
I grouped all of the JQL terms together, separated them with spaces and AND clauses, dropped the double-quoting around some of the parameters, and then URL encoded the whole thing.

Get Salesforce Product List and Data

Can I get salesforce product list using REST API? Or can you provide better and easier way to get product list. Please help. Thank You
Yes, Product2 records can be queried through the REST API. Here's a sample query:
curl -H 'X-PrettyPrint: 1' \
-H 'Authorization: Bearer ##Session_Id##' \
https://ap4.salesforce.com/services/data/v42.0/query?q=SELECT+Id+FROM+Product2

Single quote in bash script curl command keeps getting converted to double quote

Seen many related posts but nothing has helped me resolve my issue. I have a CURL command in a bash script. The Data element contains a SQL command. The SQL command includes a param that must be single quoted. So, it looks like this:
jsonData=$(curl --request POST \
--url $uribase/Redrock/Query \
--header 'content-type: application/json' \
--header 'X-NATIVE-CLIENT: 1' \
--data '{"Script":"'"Select Server.ID, Server.ComputerClass, Server.FQDN, Server.Name, Server.SessionType from Server WHERE Server.ComputerClass='Unix' COLLATE NOCASE"'"}')
I've tried so many variations on quoting the Server.ComputerClass value to no avail. I can't get it to resolve to ='Unix'. Even tried \u0027 unicode.
Any help appreciated.
Rather than trying to quote it correctly, feed it to curl from a here document via standard input. Use an array to allow you to organize the options more cleanly as well.
curl_opts=( --request POST
--url "$uribase/Redrock/Query"
--header 'content-type: application/json'
--header 'X-NATIVE-CLIENT: 1'
--data #-
)
The #- tells curl to read the data from a file named -, which is a curl-defined alias for standard input.
jsonData=$(curl "${curl_opts[#]}" <<EOF
{ "Script": "Select Server.ID, Server.ComputerClass, Server.FQDN, Server.Name, Server.SessionType from Server WHERE Server.ComputerClass='Unix' COLLATE NOCASE"}
EOF
)
Quoting gets confusing fast. Yes, using a file to store the statement will work ; if you prefer not to do that, then here is something you could try.
Create a function :
sql_request()
{
printf "'{"
printf '"Script"'
...
}
You get the general idea : break it down in as many pieces as needed ; when you need a single quote enclose it in double quotes, when you need a double quote, enclose it in single quotes.
You can then call that function as needed to get your request :
"$(sql_request)"
You can even easily feed arguments into this function to change portions of the string.

How to Display "title" and "displayvalue" from smart sheets using the cURL code shown below?

curl https://api.smartsheet.com/2.0/sheets/5848567060424580/columns/4140686686611332 -H "Authorization: Bearer 21txb6n2ajlf6dhsil8g3jxtdu"
^^^^That is the curl command i put into the terminal and when i do, i get this information poster below. The access token: 21txb6n2ajlf6dhsil8g3jxtdu & Sheet ID:5848567060424580. I want to get a curl command that only displays certain values instead of every single ID and formatting option in the columns from the Smartsheet. Any help would be useful thanks!
{"id":4140686686611332,"index":2,"title":"Column3","type":"TEXT_NUMBER","width":150}MAC-C02Q3C5MG8WP:~ jxs18$ curl https://api.smartsheet.com/2.0/sheets/584856724580 -H "Authorization: Bearer 21txb6n2ajlf6dhsil8g3jxtdu"
{"id":5848567060424580,"name":"JagTestSheet","version":1,"totalRowCount":3,"accessLevel":"EDITOR_SHARE","effectiveAttachmentOptions":["FILE","ONEDRIVE","GOOGLE_DRIVE","EVERNOTE","BOX_COM","EGNYTE","DROPBOX"],"ganttEnabled":false,"dependenciesEnabled":false,"resourceManagementEnabled":false,"cellImageUploadEnabled":true,"userSettings":{"criticalPathEnabled":false,"displaySummaryTasks":true},"permalink":"https://app.smartsheet.com/b/home?lx=PoM3LKb9HF6g_jsJ9JoWwg","createdAt":"2016-07-07T14:44:38Z","modifiedAt":"2016-07-07T15:22:53Z","columns":[{"id":1888886872926084,"index":0,"title":"Primary Column","type":"TEXT_NUMBER","primary":true,"width":150},{"id":6392486500296580,"index":1,"title":"Column2","type":"TEXT_NUMBER","width":150},{"id":4140686686611332,"index":2,"title":"Column3","type":"TEXT_NUMBER","width":150},{"id":8644286313981828,"index":3,"title":"Column4","type":"TEXT_NUMBER","width":150},{"id":481511989372804,"index":4,"title":"Column5","type":"TEXT_NUMBER","width":150},{"id":4985111616743300,"index":5,"title":"Column6","type":"TEXT_NUMBER","width":150}],"rows":[{"id":6858731183990660,"rowNumber":1,"expanded":true,"createdAt":"2016-07-07T15:22:53Z","modifiedAt":"2016-07-07T15:22:53Z","cells":[{"columnId":1888886872926084,"value":234.0,"displayValue":"234"},{"columnId":6392486500296580,"value":657.0,"displayValue":"657"},{"columnId":4140686686611332,"value":875.0,"displayValue":"875"},{"columnId":8644286313981828},{"columnId":481511989372804},{"columnId":4985111616743300}]},{"id":1229231649777540,"rowNumber":2,"siblingId":6858731183990660,"expanded":true,"createdAt":"2016-07-07T15:22:53Z","modifiedAt":"2016-07-07T15:22:53Z","cells":[{"columnId":1888886872926084,"value":564.0,"displayValue":"564"},{"columnId":6392486500296580,"value":546.0,"displayValue":"546"},{"columnId":4140686686611332,"value":453.0,"displayValue":"453"},{"columnId":8644286313981828},{"columnId":48151198937280MAC-C02Q3C5MG8WP:
You could consider piping the output into something like jsawk
to query the JSON response for what you are looking for from your cURL request.