Any default APIs in Dolibarr for creating sales order records? - rest

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).

Related

Create aggregated object for a batched REST call in Azure Data Factory

I need to upload a bunch objects to a REST API and I want to aggregate them into batches when I send them in JSON. Unfortunately, the batch object needs to be in a specific JSON format, and I'm having difficulty creating the correct Data Flow in ADF.
The data looks something like this:
CustomerId
Name
Country
1
Alice
USA
2
Bob
CAN
3
Charlie
MEX
For examples sake, I need the data in batches of 2, and when making the REST API call, the JSON data should looks like this:
Batch 1
{
"customers" : [
{
"name" : "Alice",
"country" : "USA"
},
{
"name" : "Bob",
"country" : "CAN"
}]
}
Batch 2
{
"customers" : [
{
"name" : "Charlie",
"country" : "MEX"
}]
}
Can someone help me understand how to write a Data Flow that does this?
This can be achieved with a dataflow like this example Data flow.
Steps:
Create a sample source data. (example source)
Create derivedColumn as below (example derived column):
column_value_1: it’s used to generate rownumber
test: It’s used to create a JSON data like:
{
"name" : "Alice",
"country" : "USA"
}
Create a window activity to generate a rowNumber column.
example window Sort, example window column
Aggregate configuration for Group By uses the expression below. (example Aggregate Group By)
toInteger(divide(rowNumber,2))`
Aggregate configuration for Aggregates uses the expression below. This is used to generate the JSON of customers (example Aggregate Aggregates)
collect(test)
Exclude unnecessary columns and remove the mapping of Group. (example sink config)
Results
The REST API server side will receive the body like this

Updating relation in Hybris data using REST API, nested relation not saved

I've implemented tree structure and want to save items to database. Every item has "children" field with list of child nodes.
But if I send PUT request with something like this:
https://localhost:9001/ws410/rest/pdsfamilies/8796093098749
{
"children": [
{
"pk": "8796093164285"
}
]
}
I'm getting response 200 OK but of course "children" list doesn't update. If I pull the item using GET again, it doesn't contain that change.
What am I doing wrong?
The solution was weird nested object structure like this:
{
"children": {
"pdsFamily" : [
{
"pk": "8796093164285"
}
]
}
I don't know why another property pdsFamily was needed.
Also another weird thing is that in the response from GET I'm getting similar structure but the property is all lowercase pdsfamily... I have to create separate dtos for response and request just because of that...

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).

Find DocumentId through Discovery GUI tool

I want to train my Discovery collection where I have already uploaded over 200 documents. I uploaded these documents through the GUI. Looking through the Discovery documentation, I know that I have will have to make API calls to train my collection since the training API has not been exposed through the GUI yet. As part of the training API calls I need to include a document that looks like this:
{
"natural_language_query": "{natural_language_query}",
"filter": "{filter_definition}"
"examples": [
{
"document_id": "{document_id_1}",
"cross_reference": "{cross_reference_1}",
"relevance": 0
},
{
"document_id": "{document_id_2}",
"cross_reference": "{cross_reference_2}",
"relevance": 0
}
]
}
My question is how should I get the documentIds for the documents that I have already uploaded? Is there a way to find this through the GUI? Or perhaps an API call that will return something like:
{
"document_name" = "MyDocument1",
"documentId" = "the_document_id_for_MyDocument1"
},
...
{
"document_name" = "MyDocumentN",
"documentId" = "the_document_id_for_MyDocumentN"
}
Or would the only way to get the documentIds would be to create a new collection and upload all of the documents through API calls directly and track the documentIds as I get them back?
Using the GUI, perform the following steps:
Input term(_id) in the "Group query results (Aggregation)"
textbox.
Under "Fields to return", select "Specify" to input
extracted_metadata
Note, that query and filter inputs should remain empty

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.