Adding a second CustomerLocation in Acumatica via REST API - rest

For many of our customers we have additional addresses that they used over the years. We would like to add them as additional CustomerLocations. I don't seem to be able to this however and nothing turns up in google search. I'm using Postman and do a PUT on the CustomerLocation endpoint. Here is the request body
{
"CustomerID": {"value": "<CUSTOMER_ID"},
"LocationID": {"value": "SECONDARY"},
"LocationName": {"value": "Secondary"},
"AddressOverride": {"value": "True"},
"Contact": {
"Address": <address data follows>
The exception says "Object Reference not set to an instance of an object."
Has anybody done this before?

Try using "Customer" instead of "CustomerID", thats the name of the field. The inconsistency is maddening, I know

Related

Azure devops Server 2019 - Error while creating Workitem states

I am trying to create a state for existing work item.
For Get, the url will show the list of States under Bug.
But am facing an issue when I do Post with json.
https://{server}/{collection}/_apis/work/processes/{processid}/workItemTypes/Microsoft.VSTS.WorkItemTypes.Bug/states?api-version=5.0-preview.1
Json:
{"name": "Test-Status", "color": "007acc", "stateCategory": "InProgress", "order": 3 }
Below is the error details
Http - 404 - NotFound
{ "$id": "1", "innerException": null, "message": "VS402805: Cannot
find work item type with reference name
'Microsoft.VSTS.WorkItemTypes.Bug' in process named
'dcdcc713-ebc6-4940-aa9d-d6c9d3e00e39'.", "typeName":
"Microsoft.TeamFoundation.WorkItemTracking.Server.Metadata.ProcessWorkItemTypeDoesNotExistException,
Microsoft.TeamFoundation.WorkItemTracking.Server", "typeKey":
"ProcessWorkItemTypeDoesNotExistException", "errorCode": 0, "eventId":
3200 }
Any help regarding this is appreciated.
The problem should be:Microsoft.VSTS.WorkItemTypes.Bug. I think you need use the format like processName.typeName. In addition the original process cannot be customized , only the inherited process can be customized.
Here I test your api in postman,it can work well.
I had the same problem.
When you create a new process, all the Work Item Types from the Parente process (Agile, Scrum, etc.) starts with the Microsoft.VSTS.WorkItemTypes.(Epic, Bug, etc.) and you can't modify it, you will have the error:
"VS402805: Cannot find work item type with reference name 'Microsoft.VSTS.WorkItemTypes.Bug' in process name ..."
To solve this, you just need to create a new work item type that inherits that work item type that you want to use, post example:
POST https://dev.azure.com/{organization}/_apis/work/processes/{processId}/workitemtypes?api-version=6.0-preview.2
{
"referenceName": "ProcessName.Issue",
"name": "Issue",
"description": "your description",
"color": "B4009E",
"icon": "icon_traffic_cone",
"inheritsFrom": "Microsoft.VSTS.WorkItemTypes.Issue"
}
I hope it helps.
Have a nice day!

What's the RESTful way to return metadata on a collection of resources?

Say I have a REST API for accessing user notifications. I have an endpoint for getting all notifications:
GET https://server:443/api/notifications
Which returns the following response:
[
{
"status": "unread",
"_id": "5db8228d710ab4b1e33f19b2",
"title": "Some title",
"time": "2019-10-29T11:29:17.402Z",
"details": "Some details...",
"user": "user1"
},
{
"status": "unread",
"_id": "5db8228d710ab4b1e33f19b3",
"title": "Some title",
"time": "2019-10-29T11:29:17.411Z",
"details": "Some other details",
"user": "user2"
},
]
Now, I'd like to also be able to retrieve the amount of notifications for each user in a single request, for which the response will be something like:
[
{
"user": "user1",
"count": 1
},
{
"user": "user2",
"count": 1
},
]
What would be the best way, in terms of REST conventions, to do that?
What would be the best way, in terms of REST conventions, to do that?
REST really doesn't answer that. REST tells you that you have resources, but it doesn't actually offer any opinion on where the "boundaries" of your resources should be.
Again, think "web pages". You could add your summary to the web page that describes notifications, and that would be fine. Or you could decide that the notifications are described on one web page, and the summary on a different web page, and that would be fine.
What REST does tell you is that caching is important; so if you think the cache controls for summary data should be different from notification data, then you want to be thinking about separating that data into a different resource. If you think the summary data and the notification data needs to be synchronized, then its more likely that they belong as part of the same resource.
Of course, there's nothing in REST that says you can't have multiple resources that return the "same" data.
If you wanted the summary to be part of the notifications resource, and also wanted that information to be independently identifiable, then you would use a fragment to describe the summary "sub-resource"; perhaps https://server:443/api/notifications#summary.

Acumatica api branch cannot be empty

The Branch field is present in the JSON, but Acumatica ignores it, and says that 'Branch cannot be empty'.
The api endpoint is /acumaticadb/entity/Default/17.200.001, and I am PUTting JSON to /SalesOrder, trying to create a new order.
The branch field is present in the json on the details level. I tried 'Branch' and 'BranchID' on both order header and order details levels, and still getting the same error.
I tried to specify the branch during login request. Still same error during order creation.
The exact text of the error: "PX.Data.PXException: Error: 'Branch' cannot be empty."
The stack trace is not very informative, it says error was thrown when it tried to persist the order.
Through the web UI, orders with items can be created just fine, by the same user.
This question is almost idential to /49039152, but there was no resolution there.
EDIT: Did not notice code did not come through, here is the request:
PUT : http://localhost/acumaticadb/entity/Default/17.200.001/SalesOrder
{
"Details": [{
"OrderQty": {"value": "10"},
"BranchID": {"value": "HQ"},
"Branch": {"value": "HQ"},
"InventoryID": {"value": "CONBABY1"}
}],
"CustomerOrder": {"value": "TOYONEILLTEST"},
"LocationID": {"value": "MAIN"},
"CustomerID": {"value": "TOYONEILL"},
"BranchID": {"value": "HQ"},
"Branch": {"value": "HQ"}
}
Branch screenshot:
Hq Branch
I spent hours trying to fix this and finally came to a solution. The problem for me was that the user that I was using for the API did not have the user role required to access the specified branch/company. It was a case of a very misleading error message. I think I'm using the same "Sales Demo" test data as you. I'm a bit late to the party but I hope this helps others.
To fix:
Go to the companies screen and find the access role for the company.
Add that role to your API users roles from the users screen.
In case anyone else comes across the same error and #micwallace's solution didn't work for you.
If you're specifying the optional branch parameter in your login call, it might be worth double checking that you've used the Branch ID and not the Branch Name as value, which can be found on the Branches screen.
e.g. If we were to look at the 2019R1 Sales Demo screenshot attached, and wanted to use the Products Retail branch from the Revision Two Products company, the correct value to use in the login call would be PRODRETAIL.
{
"name" : "{{api_username}}",
"password" : "{{api_password}}",
"company" : "{{tenant_login_name}}",
"branch" : "PRODRETAIL",
"locale" : "{{locale_code}}"
}
This worked for me:
Go to the companies screen and find the access role for the company.
Add that role to your API users roles from the users screen.

Can someone explain, what does the webhook do in api.ai?

I am new to api.ai. I want to send data to the web server and receive it and then give it to the users? From the documentation that I read, I understood that I have to use a webhook. But I am not sure how will api.ai send and receive the data?
Can the webhook be developed in any language?
The webhook is a web service that you implement in any language and on any platform, with an HTTP (must be https for ghome) and JSON interface, that fullfils (in their lingo) a user intent.
API.AI matches a user utterance to an intent (which then suggests entity values and a response) and they pass these in the call to your web service. You do whatever processing you need - your domain logic - and then return a speech response for the user and optionally some API.AI contexts.
You can read more about it (and about slot filling fulfillment which is a little different) here.
You can visualize the working of a webhook like a block where data request comes in JSON format somewhat like this:
{
"id": "7aef9329-4a32-4d59-b661-8bf380a0f35b",
"timestamp": "2017-06-07T05:36:12.641Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "hi",
"action": "order.pizza",
"actionIncomplete": true,
"parameters": {
"address": "",
"crust": "",
"sauce": "",
"size": "",
"time": "",
"topping": "",
"type": ""
}
}
}
and another json file is returned to it according to the prescribed settings.

Facebook API for extracting basic(Public) profile info of a person

Actually I want to extract basic(Public Profile) information of a person on Facebook by it's name or email-ID without any type of authentication. So, can anyone tell me the detailed procedure how i can acheive this using Java Programming and i want the result in XML format
https://graph.facebook.com/4
Will give you a result similar to -
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
That will give you all the public information about a user. The response you get is a JSON object. If you want it in XML you'll have to manually convert it.
Beaware that not all USER_ID's will return information. It all depends on the user's privacy settings.
I have no knowledge of JAVA so I can't give you and code samples, but you can make a simple HTTP request to that URL using whatever methods you feel comfortable with...