How to Get / Update Customer GL Account info via Rest API - rest

I'm trying to figure out how to Get and Update a Customer's GL Accounts info via Rest API.
As seen in this screenshot, a Customer's GL Accounts section has fields such as:
AR Account
AR Sub
Sales Account
Sales Sub
etc.
Via Rest API, where can I retrieve this Customer's above info, and how can I update them accordingly?
I'm able to perform CRUD for all the other Customer entity fields, but I'm quite lost regarding how per Customer GL Accounts can be retrieved and updated. Looking for any help to point me to the right direction.

Those fields are not the part of the Default endpoint, so you need some tricks to retrieve or update them.
You can either use custom endpoint or retrieve/update these fields using 'Custom' fields collection.
As for custom endpoint, here is the link that can help.
As for the custom fields, you can retrieve the values like that:
GET: {{sitename}}/entity/Default/20.200.001/Customer?$custom=DefLocation.CSalesAcctID, DefLocation.CARAccountID
Response:
{
"id": "90f25585-fbc0-eb11-9d4f-3ce1a14ed5bf",
"CustomerID": {
"value": "AAA"
},
"custom": {
"DefLocation": {
"CSalesAcctID": {
"type": "CustomStringField",
"value": "40000"
},
"CARAccountID": {
"type": "CustomStringField",
"value": "11000"
}
}
}
}
See here how to get the field names.
To update the fields you send them in the body the same way you get them in the response

Related

Azure DevOps Picklist howto know which ID is for what picklist?

When I GET the picklist by id using the REST api, it returns a json like this.
{
"items": [
"Orange",
"Blue"
],
"id": "65a8a40d-6c22-45ce-af0a-bdfdfdfd335",
"name": "picklist_aef2c045-0d2d-4f92-kjdf-56eea553e1ef",
"type": "String",
"isSuggested": false,
"url": "https://dev.azure.com/organization/_apis/work/processes/lists/65a8a40d-6c22-45ce-af0a-bdfdfdfd335"
}
My current aim is to make a script that updates the items within a picklist, but in order to update, I need to know the id of that picklist. All I know from azure devops is the label of the picklist. Is there a way to get the corresponding id with the label? Or is there an alternative? Even if I get the entire list of all picklists within the collection, it still doesn't tell me which is associated to which label so it's not usable for me.
Is there a way to get the corresponding id with the label? Or is there an alternative?
The essence of Picklist is the work item field.
You could get the target PickList id with the Rest API: Fields - Get or Fields - List.
The custom picklist field name: custom.fieldname.
For example:

Issue populating assignment_group in servicenow via REST API

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

How to retrieve multiple users at once with the GitHub API?

I'm able to get a single user, or all users created since a timestamp, or where there is some search match with the GitHub API.
https://developer.github.com/v3/users/#get-a-single-user
https://developer.github.com/v3/users/#get-all-users
https://developer.github.com/v3/search/#search-users
What I haven't been able to figure out is if there is a way to send something like a list of logins and get back all of those users at once.
My use case is that I'm pulling back a list of members off of an org. This provides me with enough data that I could loop through each individual user and get the detailed user data that I need this way, but I would rather not be hammering GitHub's API with a bunch of extra requests if it is not necessary.
Using GraphQL API v4, you could build a dynamic query with as many user you have in your array & use aliases for each one :
query {
user1: user(login: "aisalmi") {
...UserFragment
}
user2: user(login: "bertrandmartel") {
...UserFragment
}
user3: user(login: "molokoloco") {
...UserFragment
}
}
fragment UserFragment on User {
login
name
}
I also use a fragment to avoid field duplication
Test it in the explorer

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

Updating BigCommerce Pricing in Bulk with API

I am trying to figure out the best way to update our prices via the API
Normal SKUs are fine, but the price of items with options seems a little less straightforward.
Using the GET v2/products?sku=XXXX there is only the base price of the item, not the price of the item with the option(s) selected
We also need the SKU of the item when the option(s) is(are) selected as my updated price list has SKU and Price
What is the best method of gathering this information, and then updating the prices?
Thanks for your help!
The V3 API provides a much better interface for this.
If all of your product's options are related to SKUs, you can GET all of the details of the product with its variants via
/v3/catalog/products?include=variants
This will show you option information along with all pricing - the calculated_price property will give you an idea of what the real price will be when you click on the option values for that SKU on the storefront - so it will take into account (for example) Product Rules and other things that might be going on in the background.
Editing SKUs (such as their price) can also be done via the endpoint.
Example:
PUT /v3/catalog/products/6606?include=variants (where 6606 is the Product ID)
{
"variants": [
{
"id": 25858,
"product_id": 6606,
"price": 10
},
{
"id": 25859,
"product_id": 6606,
"price": 11
},
{
"id": 25860,
"product_id": 6606,
"price": 13
}
]
}
This would update the prices of these 3 variants on the product (you'd get their IDs from the GET response).
If the product is "simple", meaning it has no child SKUs, you'll also see the product represented as a variant with sku_id=null. So you can actually use this endpoint to update the prices of simple products as well.