Timesheet Entry into Project Server Using Rest API - project-server

I'm trying to add timesheet entries against some specific task which is available in the MS Project Server 2013. I have ways of creating TASK in Project Server using REST endpoints, but could not find a way straight forward for the timesheet. I have gathered few details out of some scrutiny at my end:
To See the Complete Meta Data:
http://>/PWA/_api/ProjectData/$metadata - You can get the field details, Where as I need to know in specific the Entity for TimeSheet.
To See the Complete Time Sheet Period Available:
http://>/PWA/_api/ProjectServer/TimeSheetPeriods - You can see all the available TimeSheet Periods.
I know TimeSheet stays as separate entity and doesn't belong to usual Project Entities.
My Query here to know in specific the Entity that is dealt for timesheet add & update. Please help me with endpoints including the save, publish and checkout!

How are you adding the tasks? Http requests? Did you develop some app?
I tried a few ways to add actuals to timesheets already created using REST endpoints, via Postman, without success. It always responds with this error: "The security validation for this page is invalid.", I think I'm missing some headers.
This endpoints were as close as i got:
Submit Timesheet
POST - http://>/pwa/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/submit(comment)
Update Timesheet
POST - http://>/pwa/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/update()
I saw this endpoints here.
Hope this helps!

Incase anyone is still struggling with this as I was.... here's what worked for me. To replace the actual work for a given day in a task - to enter your time:
Uri:
http://<sitecollection>/<site>/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/Lines('lineid')/Work('yyyy-MM-dd')
Method: PATCH
Headers:
Accept - application/json;odata=verbose
Content-type - application/json;odata=verbose
Odata-version - 3.0
If-Match: *
Body:
{
"__metadata": {
"type": "PS.TimeSheetWork"
},
"ActualWork": "10"
}
I entered in my times as 10 hrs.

Related

Azure data factory pagination doesn't work

I am working on a pipeline which executes oAuth2 flow in order to access REST API json data. Once I have the bearer token I am executing a request which returns the following structure:
As you can see, since the response is quite large, there's paging enabled and as part of the response I get a link to the next page. In order to get to that resource I need to also present MS-ContinuationToken in the headers. So, this is how I basically do it in the config of the Copy activity that I use to get the data from the REST endpoint:
and the issue here is that I only get the first 2000 rows and the next page(s) don't seem to be visited at all. Pipeline executes successfully and only the first 2000 items are fetched.
NOTE: continuationToken and links.next.headers.value have the exact same values from the initial response.
Even if you fix the other issue you’ll have an issue with the “next” URL not including “v1”. This is a known issue in the partner center api team. I’ve escalated it pretty high. But they don’t want to break backwards compatibility by changing the “next” URI to include the v1 or to be relative. They are considering other options but I wouldn’t hold your breath.
I would ditch the idea of using data factory and instead write a .NET console app using the partner center SDK
(You might think to paginate manually with loops etc but the Copy activity doesn’t return eg the http headers, so you will need a complex set up to somehow store the data in a data store and be able to look up the last page in order to get the continuation token. I couldn’t figure it out)

Acumatica REST API Endpoint Action Call fails

** NOTE: Any StackOverflow question that is critical of Acumatica will get down-voted.
I am trying to get a REST Web-Service-Endpoint Action working.
Extending the Default endpoint, I added an Action CreateShipmentAction.
URL: .../17.200.001/SalesOrder/CreateShipmentAction
SEND: {'entity':{'OrderNbr':{'value':'ME050225'},'OrderType':{'value':'SO'}},'parameters':{'value':null}}
METHOD: post
and this works fine.
Following the same procedure, I added CancelPurchaseOrderAction to Purchase Order.
URL: .../17.200.001/PurchaseOrder/CancelPurchaseOrderAction
SEND: {'entity':{'OrderNbr':{'value':'ME006802'},'OrderType':{'value':'DP'}},'parameters':{'value':null}}
METHOD: post
fails with "The Cancel Order button is disabled". Manually checking the PurchaseOrder, the Cancel-Order button is active via the website.
If I change the 'entity' OrderNbr to
SEND: {'entity':{'OrderNbr':{'value':'xxxME006802'},'OrderType':{'value':'DP'}},'parameters':{'value':null}}
which shouldn't match anything, I get the same error. It's like my 'entity' for the PurchaseOrder is not formatted correctly.
I would look up the necessary formatting for the 'entity' of PurchaseOrder in the Acumatica documentation, but I can't find any documentation. The VIEW_ENDPOINT_SERVICE documents do not spell this out either, which I think they should (else why have an API if the parameters are not defined...)
This issue is inconsistency in Acumatica fields.
While the website URL for a PurchaseOrder has
?ScreenId=PO301000&OrderType=DP&OrderNbr=ME006802
Making one think the 'entity' fields for a REST Action API call would be
{OrderNbr:{value:"ME006802"},OrderType:{value:"DP"}}
It's actually (note the OrderType is now just Type with a different value)
{OrderNbr:{value:"ME006802"},Type:{value:"Drop Ship"}}
Programming to Acumatica's REST API is like Whack-A-Mole.... randomly try different things (since there is no documentation) and hopefully one may just luckily work....
One thing for sure is that when dealing with Acumatica Web Service, you need to work with the screen in the browser as well.
The Web Service can only do the same thing that are possible to do on the screen.
So if you go to the Purchase Order Screen and look at the record is the Cancel Order button enabled?
I notice something when I was testing this is that for the Sales Order and the Purchase Order, the same steps will not enable both actions. At least with the default settings one is getting when using the Sales Demo Data provided with the installer.
For the Sales Order, the record only need to not be "On Hold" in order for the action Create Shipment to be enabled.
Though for the Purchase Order, you not only need to not be "On Hold", you also need to have used the Approve action before the Cancel button gets enabled.
If I were to use the Cancel Order action before these were done, I was getting the same error as you are noting in your question but once these steps were done I was able to Cancel the Order properly.
The Request that I used were to following
Sales Order
.../entity/DefaultPlus/17.200.001/SalesOrder/CreateShipmentAction
{
"entity":
{
"OrderType":{"value":"SO"},
"OrderNbr":{"value":"SO004264"}
},
"parameters":
{
"ShipmentDate":{"value":"06/05/2019"},
"WarehouseID":{"value":"RETAIL"}
}
}
Purchase Order
.../entity/DefaultPlus/17.200.001/PurchaseOrder/CancelPurchaseOrderAction
{
"entity":
{
"Type":{"value":"Normal"},
"OrderNbr":{"value":"PO000701"}
}
}

REST expected behavior of entity filter within collection

Could somebody help to find out the expected behavior in filtering data within REST.
I have an ordinary REST-service with API
GET /api/articles <-- extract all articles
GET /api/articles?category=1 <-- extract all articles belonging the
particular category
I have doubts regarding the second stuff. What must a request return if user set an invalid category. There're 3 options:
return all articles
return an empty collection
return error
I suppose that it might be up to me, but anyway I wonder whether somebody have implemented this and how he/she resolved it.
You have answered your question yourself, but to provide you an example how this is already implemented (in numerous cases) but just pointing to one such example using JIRA.
You can use JIRA's REST APIs to GET the ticket details and which is what I'm showing you here:
Using CURL, I've tried to get the ticket details providing an invalid JIRA ticket id and the above is the response that I received.
It is up to us to decide upon what needs to be the outcome of the REST APIs that we develop, just pointing out one of the scenarios from JIRA REST APIs where they chose to error out (instead of showing no response or etc).
Hope this answers your question well!

How to modify System.CreatedBy field in VSTS via API call

Apologies if this is very naive question. New to VSTS...
We are thinking to use VSTS for our daily project works. Currently, we are on old TFS hosted in-house. We have window application which is data entry tool and when any error generated Staff can raise support request via clicking one button which includes all traceback and any other necessary information for us to debug or they can raise new support work. We are thinking to integrate VSTS for our support work as well by calling API endpoint to create a task in VSTS.
I am thinking to use one service account in code that calls API to create a work item in VSTS however, I need to update System.CreatedBy field to the actual user rather than service account who raises this work item. I have seen numbers of other posts which says its read-only field.
The process is, I create a work item and then update CreatedBy field by calling following endpoint.
https://XXXXXX.visualstudio.com/DefaultCollection/_apis/wit/workitems/11?bypassRules=true&api-version=1.0
passing following JSON
[
{
"op": "replace",
"path": "/fields/System.CreatedBy",
"value": "Test, Mr <Test#example.com>"
},
]
This doesn't update the field.
Is there any way I can update this field? Thanks for your time.
Well, just read this https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-6.0#update-a-link
NOTE: System.CreatedBy and System.CreatedDate can only be modified using bypass rules on work item creation, i.e. the first revision of a work item.

Parse REST API - Push Notification with Custom Data (and where query)?

I've been using Parse REST API for push notifications to targeted users (using "where"), it works well . I am now trying to add a custom data field so the devices can handle a tapped notification (i.e. redirect to specific object id etc). From what I have read, I should add the custom properties in the data json node, at the same level as alert, like the documented example below. But every time I make the request I get a 400 Bad Request. But, when I use the Parse.com web console with json: { "alert":"Notification Message","CustomObjectId":"12345" } ... it works - I see the CustomObjectId in the push notification (on the parse.com push tab).
Why is my REST API request failing, but the seemingly same request on the Parse.com website console is working? What am I missing?
My Parse REST Request:
{"where":{"UserId":"MyUserId"},"data":{"alert":"Notification Message","CustomObjectId":"12345"}}
Example from documentation (note this is using channels, not a where though) https://parse.com/docs/rest/guide/#push-notifications :
{
"channels": [
"Indians"
],
"data": {
"action": "com.example.UPDATE_STATUS",
"alert": "Ricky Vaughn was injured during the game last night!",
"name": "Vaughn",
"newsItem": "Man bites dog"
}
}
Thank you for the help,
Tim
For anyone else running into this, make sure you have "REST push enabled?" set to true in your Parse settings on the website. It's defaulted to false. Parse seems to allow 5 or so requests through per day with "REST push enabled" set to false. So after you wire this up, you may think you've successfully integrated with Parse, but then you start getting 400 Bad Request errors. This would lead many to think the issue is with their code possibly malforming requests or missing required parameters, not an authorization level issue like "REST push enabled" is not allowed.