Important Update: Some Community URL Redirects are Under Maintenance. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Reference FIeld ID

PaulCasey2
Collaborator II

The Rest API document does not include a body example for Get Content by Reference Field ID. I would like to pull all the names from a Record Permissions field. I tried different types of fields, changing the method, body, etc but I can't seem to get it right. Login, logout, etc. work just fine.

 

 

Powershell

##Get content info
$api_url = $base_url + "/api/core/content/referencefield/referencefieldid"
$body = '{"FieldIds":[18489]}'
$results = Invoke-RestMethod -Method Post -Uri $api_url -Body $body -Headers $headersGET -ContentType "application/json" -WebSession $sess
$results.RequestedObject
$results.RequestedObject.FieldContents

 

This particular code returns this error.

 

Invoke-RestMethod : {"Message":"The request is invalid."}
At C:\ScriptsTesting\REST_GetContentbyFieldID.ps1:60 char:12
+ $results = Invoke-RestMethod -Method Post -Uri $api_url -Body $body -Headers $he ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

1 REPLY 1

PaulCasey2
Collaborator II

Probably a failure on my part but I see now that not all fields have a referencefieldid. I guess it is only related record fields if I read the Rest documentation correctly, as a colleague pointed out. In this case, 18010 is a related record field, in the Authorization Package, for a link to Findings (in our instance).

 

We will keep looking for a way to pull id from a Record Permission field.

 

 

##Get content info
$api_url = $base_url + "/api/core/content/referencefield/18010"
$results = Invoke-RestMethod -Method Post -Uri $api_url -Headers $headersGET -ContentType "application/json" -WebSession $sess
$results.RequestedObject
$results.RequestedObject.FieldContents