SOLVED

Create entries in a LookupTable using Rest API

New Contributor

Hi,

 

I'm trying to add entries to a project online lookuptable using REST. I'm able to create a project via similar commands, however I cannot get the body correct to "post" the additional entry(s) to the lookup table. 

 

The remote server returned an error: (400) Bad Request.

 

I think its the Value I cannot get correct, which may be related to SP.KeyValue.

REST Interface

Supported.

PS.LookupEntryCreationInformation

http://contoso.sharepoint.com/sites/pwa/api/ProjectServer/LookupTables('{tableid}')/Entries/Add

POST Example (not all fields may be required)

body = {
	'parameters': {
		'Description':'value', 
		'Id':'value', 
		'ParentId':'value', 
		'SortIndex':'value', 
		'Value':'value'		
	}
}

Thanks

Hudson

2 Replies
Update Any Ideas???, changed URL to
http://contoso.sharepoint.com/sites/pwa/api/ProjectServer/LookupTables('{tableid}')/Entries

{
"Description": "TEST REST DESC",
"Id": "b5379034-aa95-4a05-8dd4-cfed03614d99",
"SortIndex": "0",
"Value": {
"DurationValue": null,
"NumberValue": 0,
"TextValue": "TEST REST"
}
}

Content-Type - application/json;odata=verbose
An entry without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified.

or

Content-Type - application/json

The property 'Value' does not exist on type 'PS.LookupEntry'. Make sure to only use property names that are defined by the type.
best response confirmed by Paul Mather (MVP)
Solution

Worked it out in end, started off very simple body, the journey took me down the long and frustrating path to complex body with content-type using application/json;odata=verbose. Nailed it today with the below simple body and content-type just application/json.

For anyone wanting to add an entry to lookup table within project online the below if the URL and body required ensuring the GUID is unique for each entry.

http://contoso.sharepoint.com/sites/pwa/api/ProjectServer/LookupTables('{tableid}')/Entries/Add

Powershell

 

$lookupguid = [Guid]::NewGuid()

 

$body = "{ 'parameters':
{'Description': 'TEST REST DESC',
'Id': '$lookupguid',
'SortIndex': '0',
'Value': {
'DurationValue': null,
'NumberValue': '0',
'TextValue': 'TEST REST'
}}
}"