Issue populating assignment_group in servicenow via REST API - rest

I am trying to create Servicenow incident ticket using REST API. Here is the link and body:
https://<mydomain>.service-now.com/api/now/table/incident and body:
{
"short_description":"testing short description",
"assignment_group":"Software",
"urgency":"Medium",
"impact": "Low",
"caller_id":"John Doe",
"description":"testing description"
}
Incident ticket is getting created with all fields populated as requested except assignment_group and description fields. I know these are reference fields. I tried all combination but information is not getting populated for these two fields. Any one has any suggestions? I tried for assignment_group the sys_id value also like "assignment_group":"4ikilo9f1bb43740ddfa315bcd4kmj89" and "assignment_group":{"sys_id":"4ikilo9f1bb43740ddfa315bcd4kmj89"} etc.

pass the id of the assignment group within the API call than directly giving the name of the group, this worked for me :)

Related

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

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.

Retrieve keycloak group id for a specific group

I am trying to access a group id of a specific group from keycloak. What I found is like there is no REST Api call is available for access this one. You can refer here http://www.keycloak.org/docs-api/3.0/rest-api/index.html#_groups_resource. This shows that you can access all group details or specific group details only by using their Id's. Actually what I actually need is I want to access only the id of the specific group. Can anyone let me know how to do this?
You can write it like this:
GET http://localhost:your_port/auth/admin/realms/your_realm_name/groups?search=name_of_the_group
it will return {id, name, path, subGroups} to you..
My Postman Example
The documentation you're using is pretty old. Take a look at the documentation for the latest release:
https://www.keycloak.org/docs-api/4.8/rest-api/#_groups_resource
You can provide a "search" parameter to look for groups by name.
Unfortunately, if you use the name of a subGroup, it returns the entire hierarchy starting from the top-level group, so the API for groups is still problematic.
One way is to enter keycloak admin panel. Then in the Groups option, select a group. Finally you will find the group id in the URL. Like /realms/Applications/groups/bc49dc6c-7c2a-40c4-bf60-fea8c2b1d562
You can get a list of all groups:
GET /admin/realms/{realm}/groups
The response will have group properties including id.
[
{
"id": "8ge163b3-6kc7-40ed-x069-3309eabbcbea",
"name": "group1",
"path": "/group1",
"subGroups": []
}
]
This might come a bit late, but anyway.
There is also the GET /{realm}/group-by-path/{path} endpoint which will return only the group that you desire since path is unique.
Also if someone needs (and since this isn't actually documented, or at least not as of the writing of this answer) if you want to call this endpoint from the admin-cli you can do it as follows:
./kcadm.sh get group-by-path/{path} --realm {realm}
ex.: ./kcadm.sh get group-by-path/parent_group/child_group/grand_child_group --realm realm1

How do I export GLBudgetLineDetail via Rest API?

My goal is to export data from the [GLBudgetlineDetail] table via the Rest API.
To accomplish this:
1) I created created a custom endpoint based on the Budgets screen (Finance > General Ledger > Work Area > Enter > Budgets)
!(http://imgur.com/sQC0zOI)
2) I populated the endpoint by adding all the fields from the Budget Articles container
!(http://imgur.com/tZp2GMh)
When I query this endpoint, I only get an empty array returned "[]".
Here is the query:
GET http ://servername/WebServiceAPITest/entity/MyStore/6.00.001/Budget
Headers:
Content-Type -> application/json
("Budget" is the name I gave to the endpoint)
I can successfully query other endpoints (Accounts, Vendors, JournalTransactions, etc) but I can't get any data back from this one.
I created the MyStore Demo (Course I210) and have access to the [GLBudgetLineDetail] table and can verify that it has data. On the Budgets screen, if I filter to year 2013, Ledger 'Budget', Branch 'SOFT', I can see Budget information.
How do I get access to this info via the Rest API?
Since you mentioned the Course I210, You might want to refer yourself to the section 3.4.1 about Retrieving the Price of an Item for a Customer.
In that section, they are saying that if you want to retrieve data from an inquiry, you must use the Put command:
"Because you are retrieving the price of an item from the inquiry, you will use the Put() method to obtain data."
Since the Budget Screen is an Inquiry Screen you must use the Put command to set the parameter you want.
Here is one that I tried and that worked on an Acumatica web site with demo
data:
PUT http://localhost/Demo610u04/entity/BudgetEndpoint/6.00.001/Budget
Headers (Key -> Value):
Content-Type -> application/json
Accept -> application/json
Body :
{
"BudgetArticles":[{}],
"FinancialYear":{"Value":"2016"},
"Ledger":{"Value":"BUDGET"}
}
EDIT: Looking at the image you added, you should have your budget Filter fields in the main entity and have a sub entity of type Detail containing the Budget Articles fields

Designing RESTful shopping cart

I am building a single page application for booking hotel conference rooms and am not sure how to set it up, or even if RESTful is the proper approach. There will be four steps to this SPA:
The user chooses a date (available dates come from server - some days could be fully booked).
The user chooses a conference room (conference rooms available at this hotel on the date chosen in step 1 are retrieved from the server).
The user enters their name, address, billing info.
User sees confirmation page.
This same SPA will be used by multiple hotels with the same database back-end, and for the front-end I was thinking Ember.
Is RESTful the right approach for this application?
I was thinking:
GET /dates?hotel_id=xxx (should I pass the hotel ID in the URL vs. in headers vs. in the body?)
GET /rooms?hotel_id=xxx&date=yyy (should I be passing the date and hotel_id in, or somehow remember it on the server?)
POST /order with body: {date, conference_room_id, name/address/billing info}, returns { confirmation_id }
Should the name/address/billing info be put into a separate POST?
Thank you for your advice.
In a REST(ful) framework there's no concept of session. Every request must send all the required information in order to identify a resource.
I'll post an example below, based on requirements you provided.
GET /hotels/{hotel_id}/dates
Path params:
hotel_id (required)
Query params:
startDate (optional, default: today)
endDate (optional, default (example): today + 3 months)
status (optional, "available"/"booked"/"all", default: "all")
Response body: [{"id":"20160503", "dateStr":"May 5th 2016", "status": "available"}]
GET /hotels/{hotel_id}/dates/{date_id}/rooms
Path params:
hotel_id (required)
date_id (required)
Query params:
status (optional, "booked"/"available"/"all", default:"all")
Response body: [{"id": "12", "status": "available", "reservationId": ""}, {"id: "13", "status": "booked", "reservationId" : "123"}]
Note: this kind of implementation allows to list different combinations of dates and rooms (e.g. booked rooms in available days).
POST /hotels/{hotel_id}/reservations
Path params:
hotel_id(required)
Request body: {"dateId":"20160503", "roomId":"12", "firstName":"John", "lastName":"Doe", "address": "xxx", "vatNumber" : "yyy", "companyName": "zzz"}
Note: if you store billing addresses as separate entities (e.g. if your server is required to "remember" them), then it can be useful to implement POST and GET services for billing addresses (/billing) and refer to them with proper identifiers.
Response body: {"reservationId" : "324"}
GET /hotels/{hotel_id}/reservations/{reservation_id}
Path params:
hotel_id(required)
reservation_id (required)
Response body: {"dateId":"20160503", "roomId":"12", "firstName":"John", "lastName":"Doe", "address": "xxx", "vatNumber" : "yyy", "companyName": "zzz"} (same as POST request body)
GET /dates?hotel_id=xxx (should I pass the hotel ID in the URL vs. in headers vs. in the body?)
GET /rooms?hotel_id=xxx&date=yyy (should I be passing the date and hotel_id in, or somehow remember it on the server?)
POST /order with body: {date, conference_room_id, name/address/billing info}, returns { confirmation_id }
Your solution can use Restful API approach. Because it enable any other component to directly call your APIs. It can be APP, or a website or plugin or just another java program connected to internet, they just need to trigger your API and they are done.
URL you mentioned for your application, please note that one should use resource-based URL approach while building RESTful api.
GET /date/hotels/ -> Gives you all available rooms in all hotels on that particular day
GET /dates/hotels/ -> Give you list of available rooms for a particular hotel (Use dates/hotel_id instead of dates/?hotel_id=xxx). Parameter should be used to filter your result. E.g. dates/hotels/hotel_id?PIN=142: This should gives you hotel whose pin matches 142
dates/hotels?MAX_RECORD=50: This should give you list of hotels but limit to 50
You can find more about creating resource-based Restful API https://www.youtube.com/playlist?list=PLqq-6Pq4lTTZh5U8RbdXq0WaYvZBz2rbn
I would put the "Selects" into GETs as designed.
e.g. dates GET /hotel/:id/date -> Get all available dates
rooms GET /hotel/:id/date/:date/rooms -> Get all available rooms
per design in a RESTful API GET is defined for requesting data.
For the POST I would not breakdown into a seperate POST but you can put some parameter like hotel_id or date into the URL.
Best
Fabian