I have a dataset uploaded in following form:
SomeKey
-> Alphabet
-Emp1: "{ 'Fname' : 'Bob', 'Lname' : 'Sob' }"
-Emp2: "{ 'Fname' : 'Tom', 'Lname' : 'Mot }"
Now using Rest API, I want to edit Fname and Lname of employee with key Emp1 to Fred and Dref, and Fname and Lname of employee with key Emp2 to Kent and Tenk in one single call. Is this possible? If yes, how?
If you would like to update a single employee, you can do so with a PUT REST API call like this:
curl -X PUT -d <data> https://some.url.com/SomeKey/Employees/Emp1/.json
If would like to update multiple employees using a single REST API call, you can do so with a PATCH REST call like this:
curl -X PUT -d '{"Emp1":<data1>,"Emp2":<data2>"}' \
https://some.url.com/SomeKey/Employees/.json
Additional details about the REST API are available here:
https://www.firebase.com/docs/rest-api.html
Related
Hi I have this cURL request that I have been trying and failing to get it right, it gives me a 500 Error (Internal Error)
Please see my curl request below:
curl --location --request POST "https://api.monday.com/v2" --header "Authorization: XXXXX" --header "Content-Type: application/json" --data-raw "{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}" -v
I get back an empty object as a response but on the response header I see a 500 error message
Make sure your quotes are nested and escaped properly.
Your code:
"{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}"
You are right to begin with a double quote and you are right to escape the first set of quotes within those quotes.
However, when you get further in the query, "emailed_items" also needs to be escaped, but since you are already in a set of quotes, you actually need three backslashes.
Corrected code:
"{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \\\"emailed_items\\\", item_name: \\\"Test from Curl\\\") { id } }\"}"
Make use of the npm package for monday.com queries. One such package is monday-sdk-js
Assigning parameters could be confusing thus make use of this package which takes query as a parameter and makes things easy.
I have a REST API written in Symfony3, with help from the FOSRestBundle.
It makes use of Symfony form classes for data input (POST, PATCH, PUT actions), which works great for almost all endpoints.
However I have a child endpoint that sets up relations using a form with a single collectionType. A POST request body looks like this:
curl http://localhost/documents/100/related -d #- <<REQUEST_BODY
{
"related": [
{"id": 14},
{"id": 23}
]
}
REQUEST_BODY
However I would like to ommit the "related" field name as this information is already in the URI and seems redundant here. I would like to adjust the form to accept data like this:
curl http://localhost/documents/100/related -d #- <<REQUEST_BODY
[
{"id": 14},
{"id": 23}
]
REQUEST_BODY
But cannot see how to make a Symfony form behave in this way?
To clarify, I want to accept a single form field without having to specify the name of that field in a JSON request.
I had a similar problem a while back. What worked for me, was to use the form factory to create a named form with an empty name, like so (example when inside a typical controller):
/** #var $formFactory FormFactory */
$formFactory = $this->get('form.factory');
$form = $formFactory->createNamed('', $type, $data, $options);
Be aware that a form configured like this will consume all POST (or GET) data. So, if you can't ensure that only the required data will be present, you might need to use allow_extra_fields
I am storing phone numbers in Firebase in the E.164 format, which means they are strings beginning with a plus sign. But I am unable to successfully query the REST API if there's a '+' in the string.
So if I post this data:
$ curl -X POST 'https://<firebaseapp>.firebaseio.com/users.json' \
-d '{"deviceId": "999", "phoneNumber": "+16171234567"}'
=> {"name":"-KAE4sYw45VUehwUOoBp"}
resulting in this data structure:
users
-KAE4sYw45VUehwUOoBp
deviceId: "999"
phoneNumber: "+16171234567"
where I have indexed both the deviceId and phoneNumber fields, then the following query works:
$ curl -X GET 'https://<firebaseapp>.firebaseio.com/users.json?orderBy="deviceId"&equalTo="999"'
=> {"-KAE4sYw45VUehwUOoBp":{"deviceId":"999","phoneNumber":"+16171234567"}}
But querying the phone number field in the same way returns nothing:
$ curl -X GET 'https://<firebaseapp>.firebaseio.com/users.json?orderBy="phoneNumber"&equalTo="+16171234567"'
=> {}
I have tried various forms of URL encoding or escaping the '+' symbol but cannot get a phone number query to return successfully.
$ curl -X GET 'https://<firebaseapp>.firebaseio.com/users.json?orderBy="phoneNumber"&equalTo="%2B16171234567"'
=> {}
I'm trying to get WordPress website title using javascript and WP API plugin
I didn't find any example on how to get the site's name but I found the variable name under the entities section in the developer guide
function _updateTitle(documentTitle) {
document.querySelector('title').innerHTML =
documentTitle + ' | '+ $http.get('wp-json/name');
}
The output string of $http.get('wp-json/name') is [object Object]
Does anyone know how to use fix this?
You didn't get enough context. What's $http? What happens when you go to wp-json/name directly in your browser? Here's what I see:
[{
"code":"json_no_route",
"message":"No route was found matching the URL and request method"
}]
Here's a simple example to get you the title:
var siteName;
$.getJSON( "/wp-json", function( data ) {
siteName = data.name;
});
See more elegant solution here https://wordpress.stackexchange.com/a/314767/94636
response will not contain extra data like:
authentication: []
namespaces: ["oembed/1.0", "akismet/v1", "acf/v3", "wp/v2"]
routes: {/: {namespace: "", methods: ["GET"],…},…}
timezone_string: ""
...
_links: {help: [{href: "http://v2.wp-api.org/"}]}
According to below link, Artifactory AQL allows "Displaying of specific fields" via REST API by returning only fields of interest.
https://www.jfrog.com/confluence/display/RTF/Artifactory+Query+Language#ArtifactoryQueryLanguage-DisplayingSpecificFields
It doesn't work if I provide a list of fields, see below
Not Work - Bad request (400)
items.find(...).include("name", "repo")
Works
items.find(...).include("*")
Can anyone advise
Thanks, Jag
I suspect that the problem is related to encoding during the REST call, therefore I suggest to upload the query as a file Here is a working example:
Save the following query to file, lets call it aql.query
items.find
(
{
"repo": {"$match":"*"}
}
)
.include("name","repo")
Run the following curl command from the same directory that contains the aql.query file and don't forget to replace the templates in the command with your user name, password, host and port.
curl -X POST -uuser:password 'http://host:port/artifactory/api/search/aql' -Taql.query
In the result you will get:
{
"results" :
[
{
"repo" : "ext-snapshot-local",
"name" : "maven-metadata.xml"
},{
"repo" : "ext-snapshot-local",
"name" : "multi-3.0.0-20150705.195404-1.pom"
},{
.
.
.
}
],
"range" :
{
"start_pos" : 0,
"end_pos" : 46,
"total" : 46
}
}
As you can see that the result contains only the "item repo" and the "item name" fields.
Had the same issue. Spent quite a bit of time trying to figure this out. Couldn't find an answer online.
With a bad request(400), I printed the response text: "For permissions reasons AQL demands the following fields: repo, path and name."
This solution worked for me -
at a minimum: have repo, path, name.
ie... items.find(...).include("name", "repo", "path", "created_by")