Update multiple records for PUT in Rest API - rest

I have an API to update records in my Database. I have the endpoint as below
PUT /student/name/{name}/roll/{rollNumber}/reg-number/{regNumber}
and body as
{
"studentList" : [
{
"fathersName": "string",
"baseSubject": "string",
"age": "string",
"preferredLanguage": "string"
}
]
}
Each record is uniquely identified by the name, rollNumber and regNumber and I want to update multiple records at once (I have a list in my request body).
What is the best way to achieve this? Should I pass arrays of name, rollNumber and regNumber as path param and corresponding records in sequential order in the body inside studentList
or
I should have all fields in the body itself and nothing in the path params?
I am following OpenAPI specs.
Update: Adding some more details to my question
I have a table with Primary key as a combination of name, rollNumber and regNumber
I want to update multiple rows in a single PUT call. The fields which can be updated are passed in my request body and the fields which are used to identify the row that has to be updated are being passed in the URI as path Params.
I would like to know the correct approach and rest specification to achieve this. The two options which I have in mind have been mentioned in my question.

Related

Construct own message

I have user table, which is obviously does not outbox table. Table consist uuid and email field. I need to construct message and publish into Kafka based on this two field with next format:
{
"uuid": "11ebe013-ffd2-4523-b6b4-6318cbe7e6d1",
"email": "jaron24#example.net",
"staticObject": {
"staticProperty1": "WEB",
"staticProperty2": "random.com"
},
"staticProperty": "CREATED"
}
I don't want to create new field in table, where I can put constructed message(parameter transforms.outbox.table.field.event.payload - not suitable for this case). I want that kafka-connect construct it(with schema above) for me.
Is there any possibility to achieve this via configuration?

Translating a GUID to a text value, from an API response in a Power Automate Flow

I'm using MS Automate to solve an integration challenge between two systems we use in our Project Management lifecycle. I have a custom connector written by the vendor of System A which allows me to create a Flow in MS Automate which is triggered when a record is Created or Updated.
So far, so good. However, the method in the connector provided by System A returns the new or updated record containing a number of fields which contain value GUIDs as the fields are 'choice' type fields e.g. Department, Status etc. What I end up with is a record where Status = "XXXXXX-000000-00000-00000" etc. The vendor also provides a restful API endpoint which I can query, which returns a JSON collection of fields, which include a 'Choices' section for each field of this type which is a standard JSON which looks like:
{
"Id": "156e6c29-24b3-4413-af91-80a62a04d443",
"Order": 110,
"InternalName": "PrjStatus",
"DisplayName": "Status",
"ColumnType": 5,
"ColumnAggregate": 0,
"Choices": {
"69659014-be4d-eb11-bf94-00155df8457c": "(0) Not Set",
"c30c50e5-51cf-ea11-bfd3-00155de84703": "(1) On Track",
"c40c50e5-51cf-ea11-bfd3-00155de84703": "(2) At Risk",
"c50c50e5-51cf-ea11-bfd3-00155de84703": "(3) Off Track",
"6a659014-be4d-eb11-bf94-00155df8457c": "(4) Not Tracked"
},
Technical problem:
What I have is the GUID of the choice (not the field). I need to take the GUID, in this case "6a659014-be4d-eb11-bf94-00155df8457c" and translate it into "(4) Not Tracked" and store this in a variable to write to a SharePoint list. I need to do this for about 30 fields which are similar in the record.
I've created the flow and the connector has given me the record with a list of fields, some of which contain value GUIDs. I know which fields these are and I have the Display Names of these fields.
I have added a HTTP call to the provided API endpoint (lets call it GetFields), which has returned a 200 response, the body of the response containing a JSON collection of the 50 or so fields in System A.
I can't work out how to parse the body of the response for the GUID I have for each field value and ensure I have the right corresponding text value, so I can then write it to a field variable, and then create a SharePoint record, all wrapped up in an MS Automate flow.
I hope I've understood you correctly but from what I can work out, you want to dynamically select the value of the choice from the GUID you've been provided (by whatever means).
I created a small flow to prove the concept. Firstly, these two steps setup the scenario, the first being the GUID you want to extract the choice value for and the second being the JSON object itself ...
The third step will take the value from the first variable and use it dynamically in an expression to extract that key from the JSON and return the value.
This is the expression ...
variables('JSON')?['Choices'][variables('Choice ID')]
You an see I'm just using the variable in the path expression over the top of the JSON object to extract the key I want.
This is the end result ...

MarkLogic Data Hub document metadata added by steps

According to the documentation:
Document metadata added by steps
For every content object outputted by a Data Hub step, regardless of the step type, Data Hub will add the following document metadata keys and values to the document wrapped by the content object:
datahubCreatedOn = the date and time at which the document is written
datahubCreatedBy = the MarkLogic user used to run the step
datahubCreatedInFlow = the name of the flow containing the step being run
datahubCreatedByStep = the name of the step being run
datahubCreatedByJob = the ID of the job being run; this will contain the job ID of every flow run on the step, with multiple values being space-delimited
Is there any possibility to add some extra metadata keys and values to the document?
It is possible to add additional static values in your headers options or use one of these keywords to dynamically add values.
{
"headers": {
"sources": [{
"name": "loadCustomersJSON"
}],
"createdOn": "datahubCreatedOn",
"createdBy": "datahubCreatedBy"
}
}
You can also dynamically add values by using an interceptor
(See: https://docs.marklogic.com/datahub/5.6/flows/about-interceptors-custom-hooks.html) or updating the header value in a custom step if you are already using one (See:https://docs.marklogic.com/datahub/5.6/modules/editing-custom-step-module.html

Determine Correct JSON Fields for REST API based on Endpoint and Screen names (Customers & Sales Orders) - Acumatica

My project is to import Customers and Sales orders. I take a CSV file from an external program, and am to import them -- field by field -- into Sales Orders and Customers.
My challenge is determining the correct field names to get the REST API to work correctly.
I have the following fields:
I am looking to include the three fields: Description, Gift Message, and Public Comment. I inspect the element, which gives me nothing useful that I can tell. (i.e. none of the values map to the field name that I would use in JSON.)
When I go to the Endpoint for Customers, Description already exists:
And therefore, this JSON Record succeeds in an ADD or UPDATE:
{
"OrderNbr" : {"value": "SO003525"},
"Description" : {"value": "This is the Description"},
}
I extend the default customer (version 18.200.001) and I find and add the "Gift Description" and the "Public Comments" -- and they are listed as part of the "Order Summary" -- which is exactly where Description was.
However, this JSON data does add anything to Gift or Public:
{
"OrderNbr" : {"value": "SO003525"},
"Description" : {"value": "This is the Description"},
"PublicComment" : {"value": "This is the Public Comment"},
"GiftMessage": { "value": "This is the Gift Message"},
}
In talking to the (in-house) developer who set up the screen, he told me that the "Gift Message" and "Public Comments" fields were added on. But they are not showing as "User Defined" fields in the Endpoint.
Questions:
1) How can I know what the JSON structure should look like? Is there some sort of a mapping document, or a printout that shows JSON-to-Endpoint data? What I mean is that sometimes I need to use a sub-object to reference data in JSON, for example, if I want to update "Main Contact" information, I do it like this:
{
"CustomerClass":{"value":"INDIVIDUAL"},
"CustomerID":{"value":"78577"},
"CustomerName":{"value":"TEST CUSTOMER "},
"MainContact":
{
"CompanyName":{"value":"TEST CUSTOMER COMPANY"},
"DisplayName":{"value": "TEST CUSTOMER DISPLAY"},
}
}
How can I know to do that? (I know only because I saw it in the data that got returned when I added a record... Which brings up a second question:
2) Is there a way for retrieving an entire data record in its JSON format. Sort of like a : "GET - SELECT ALL - EXPAND ALL" so I can see all of the data in a record in a properly set up JSON format?
3) Any idea why the gift Message and Public Comments are showing as "Order Summary" but aren't updating like Description is?
4) Why are some things "un-expandable?" For example, I cannot expand Payments in Sales Order. I get an error:
1) How can I know what the JSON structure should look like
The easiest way is to execute a GET request. The field names are equivalent to the DisplayName property stripped of whitespaces. So if on screen the field is labelled Order Type the field name will be OrderType in the request.
To make a GET request, the URL format is /Entity/Keys.
For example entity SalesOrder has two keys: OrderType and OrderNbr.
To get entity SalesOrder of type SO and with the number SO005051 the URL would end with: /SalesOrder/SO/SO005051.
2) Is there a way for retrieving an entire data record in its JSON
format. Sort of like a : "GET - SELECT ALL - EXPAND ALL" so I can see
all of the data in a record in a properly set up JSON format?
If you want all the details, you need to specify them all in the expand clause of the GET query: $expand=Contacts,MainContact,BillingContact
The name of the details array can be looked up in the Web Service Endpoint screen SM207060. They are the tree view elements with a empty array [] suffix.
3) Any idea why the gift Message and Public Comments are showing as
"Order Summary" but aren't updating like Description is?
Those are custom fields. You need to extend the endpoint to add those custom fields otherwise they will be ignored. If there's no issue with the custom endpoint maybe the field aren't bound to database.
But they are not showing as "User Defined" fields in the Endpoint.
If by User Defined you mean those fields were added with a wizard (without programming) then this is likely the reason why they don't work in the web service. You would need to add custom field with a DAC extension which requires programming instead of the User Defined field.

PUT multiple related records in Data API request

In the documentation from FMI the HTTP-body example for creating records using FMS16 Data API (REST) looks like this
{"data":
{
"field_1": "value_1",
"field_2": "value_2",
"repetitionField(1)" : "fieldValue",
"Orders::OrderDate.0":"12/22/2015"
}
}
The last attribute Orders::OrderDate.0 sets a value to a field on a related record and since the record donĀ“t already exist it will be created.
My question focus on the .0 suffix of the attribute name. It looks to me like the 0 indicates a serial/identifier for on which related record the value should be inserted. This leads me to wonder if it is possible to create more then one related record in the same request that creates the parent record.
The below body returns error that the record does not exist, but why can one related record be created but not two?
{"data":
{
"field_1": "value_1",
"field_2": "value_2",
"repetitionField(1)" : "fieldValue",
"Orders::OrderDate.0":"12/22/2015",
"Orders::OrderDate.1":"11/11/2011"
}
}
Any clue if the above code should work? Am I missing something?
I am fully aware that I can (should) post several requests aimed at the related tables layout to create the related records. I just wish to know, since the .0 notation is in the documentation, does it should have a valid function?
Found this under the notes section in the doc you linked to:
"Only one related record can be created per create record call."
So there you have it. Looks like it behaves similarly to record creation from a portal, where you also can only create one related record at a time.