Error: adding rows with smartsheet API - smartsheet-api

I can't seem to get a add row(s) to work. I get the following error, but I believe the data is formatted correctly. Thanks in advance!
{"errorCode":1008,"message":"Unable to parse request. The following error occurred: Request body must be either a JSON object or JSON array."}
POST https://api.smartsheet.com/1.1/sheet/{sheetId}/rows
ContentType=application/json
[
{
"toBottom" : true,
"cells" : [
{"columnId" : "328984295696260", "value" : 888.0},
{"columnId" : 4832583923066756, "value" : 100.0}
]
},
{
"toBottom" : true,
"cells": [
{"columnId" : "328984295696260", "value" : 999.0},
{"columnId" : 4832583923066756, "value" : 100.0}
]
}
]

Looks like you've encountered a bug with the API 1.1 "Add Row(s)" endpoint. I get the same error as you report when attempting a similar request using the API 1.1 endpoint -- but it works fine with the API 2.0 endpoint.
I'd suggest that you try using the API 2.0 "Add Row(s)" endpoint instead:
POST https://api.smartsheet.com/2.0/sheets/{sheetId}/rows
API 1.1 has been deprecated (see announcement here), so you should be using API 2.0 for any new API development. The API 2.0 documentation can be found here.
PS - for good measure (although it's not the cause of your issue) -- I'd suggest that you remove quotation marks from around the first numerical columnId value in each cells collection, as they're not necessary.

Related

Cloud Firestore: Add/remove items in ArrayValue field via REST API's PATCH method?

I'm looking for a way to add/remove data from an ArrayValue field, via the Firestore REST API.
I'm able to send the following PATCH request, to set all values of an array fields in a document, via the following:
Request Url
/v1beta1/projects/MY_APP/databases/(default)/documents/MY_COLLECTION/MY_DOCUMENT_ID?updateMask.fieldPaths=document_array&key=MY_KEY
Request Body
{
"fields" : {
"document_array" : {
"arrayValue" : {
"values" : [
{ "stringValue" : "item_value_0" },
{ "stringValue" : "item_value_1" }
]
}
}
}
}
As expected, the document with id MY_DOCUMENT_ID in collection MY_COLLECTION updates so that the document_array field is populated with strings:
['item_value_0', 'item_value_1'].
Using the REST APIs PATCH method, I would like to add/remove/update/manipulate ArrayValue fields in my document MY_DOCUMENT_ID (ie as outlined in this question).
Is this possible? If so, how?
Thanks in advance
It's not possible today. You could file a feature request stating what you want (it's been asked before).

Any default APIs in Dolibarr for creating sales order records?

Dolibarr has a module for restful APIs.
The API explorer seems to show all the CRUD tasks for each module like orders, stock and customer.
But to CREATE a record, the sample VALUE for the POST method shows as:
{
"request_data": [
"string"
]
}
What are the specific field attributes that should go in here?
Where can I look up the field requirements?
You should take a look at the attributes of the Commande class:
https://github.com/Dolibarr/dolibarr/blob/develop/htdocs/commande/class/commande.class.php
The object should be something like this :
{
"date_commande" : "0000-00-00 00:00:00",
"date_livraison" : "0000-00-00 00:00:00",
"attribute3": "and so on"
}
When you need a parameter like
{ "request_data": [ "string" ] } for a POST API, all you have to do is to call the similar API to get a record (so the same API with the GET method). The result can be cut and paste to be used to create a new record (just change the id and ref in the answer retreived by the GET).

processing_state API returns "processing" even when the document is ready in Concept insight

Steps I followed:
First create corpus, then send create a document in it.
Check if the processing of the document is ready (done processing)
https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/{account-id}/{corpus-name}/documents/{document-name}/processing_state
If it is ready then i retrieve the related_concepts in the document
https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/{account-id}/{corpus-name}/documents/{document-name}/related_concepts
All the above steps are working (I get a 200/201 reply from Bluemix server).
The problem is in the reply of step 2. I keep getting the following response
{ "status": "processing", "last_modified": "2015-11-10T15:27:12.473Z" }
But when I do step 3, I am getting the desired response (the related concepts in the document)
{
"concepts" : [
{
"score" : ...,
"concept" : {
"id": "........",
"label": ".....
}
}, .....
]
}
UPDATE
The processing_state API problem has been fixed. Gives the desired response
The processing_state API problem has been fixed. Gives the desired response now.

How to attach a page as a child of another page in Confluence - REST API

I am attempting to use the Confluence REST API to correct the tree structure of pages on a Confluence site. I can do this manually, however there are quite a few pages and I already have the tree structure in another XML file.
Currently I am able to upload pages and images using the confluence REST API. Definitions are located here.
I have attempted to use the /rest/api/content/{id} PUT command. This requires the content to be in the body of the request. Attaching the content I had received from a previous GET request I find I have to update the version count.
The above all works. Adding to the ancestor list however doesn't seem to. If I add the parent page to the list of ancestors I get formatting errors reported back.
Added to this if I manually attach the page to another page and request its contents I find that the parent appears twice in the ancestor list. Also the history count does not increase.
The resulting JSON returned from a GET request for the page:
http://someconfluencesite.com/rest/api/content/10031361?expand=ancestors (200)
{
"id" : "10031361",
"type" : "page",
"title" : "Automatic Action Usage Updates",
"ancestors" : [{
"id" : "10031327",
"type" : "page",
"title" : "Action Lists"
}, {
"id" : "10031327",
"type" : "page",
"title" : "Action Lists"
}, {
"id" : "10031328",
"type" : "page",
"title" : "Actions Tab"
}, {
"id" : "10031327",
"type" : "page",
"title" : "Action Lists"
}, {
"id" : "10031327",
"type" : "page",
"title" : "Action Lists"
}, {
"id" : "10031328",
"type" : "page",
"title" : "Actions Tab"
}
]
}
The tree this is for looks like the following:
Space
Action Lists
Actions Tab
Automatic Action Usage Updates
This leads me to believe I am using the wrong command.
I have attempted to contact Confluence support however their authorization emails are not arriving in my inbox. So I have come here :)
So my question is what is the REST call for creating a page tree in confluence? After that, what is the format of the request body?
Edit:
The following PUT request gets a successful return code. Yet the returned object does not have the ancestor attached (not unusual as in all GET requests you have to expand to get it). The version number does not update. The two pages are not hooked to each other either.
{
"id":"10552520",
"type":"page",
"title":"Correct Page Title",
"ancestor":[
{
"id":"10552522",
"type":"page"
}],
"version":
{
"number":"2"
}
}
The nice thing the above does though is delete all the contents of the page.
The following POST call results in the page being created but having no ancestors. The ancestor exists with the id supplied. Strangely this also is created without any content in the page.
{
"type":"page",
"title":"Correct Title",
"space":{"key":"SpaceKey"},
"ancestor":[{"id":"10553655","type":"page"}],
"body":{"storage":{"value":"<p>New Page </p>","representation":"storage"}}
}
Putting the above into the REST API browser also results in the children not being attached to the parent.
So it appears the answer to my question is in the question itself.
The JSON needed to have "ancestors" not "ancestor" as the array name for the ancestors array. Once this was changed it all works for a POST request.
So if your reading this and having similar issues make sure that all the element names in the JSON your passing are correct. If they aren't, they simply are ignored.
{
"id":"10552520",
"type":"page",
"title":"Correct Page Title",
"ancestors":[
{
"id":"10552522",
"type":"page"
}
],
"version":
{
"number":"2"
}
}
It's "ancestors", not "ancestor".
To move an existing page first get it's version, space, etc.
Then call PUT with version + 1, space, ancestors, title.
pageaschild = { "type":"page",
"title":name,
"space":{"key":space},
"ancestors":[{"id":ancestorid,"type":"page"}],
"version":{"number":version}};
$.ajax({type:'PUT', url:baseURL + pageId, contentType:"application/json;charset=utf-8", data:JSON.stringify(pageaschild)});

Neo4j cypher query on ID returns no values via REST but does via Data Browser

Neo4j version 1.8.M06
The following query executed in the Data Browser on the web management interface returns a value for the Forename property:
start n=node(*) where ID(n)=147 return n.Forename
However the same query posted using the REST API
{
"query" :
"start n=node(*) where ID(n)={id} return n.Forename",
"params" :
{"id" : "147"}
}
Returns:
{
"columns" : [ "n.Forename" ],
"data" : [ ]
}
Any idea what I'm doing wrong?
You don't want quotes around 147 in the REST call.
Also, maybe it's because of your simplification, but I'm pretty sure you should really be doing start n=node({id}) instead, for optimum performance. Not sure if it optimizes that sort of thing out.