
Hi all,
I'm testing some actions using the WebAPI using both Postman and a test app. I'm seeing two different results. The Postman call to the web api works. The app's PostAsync fails with an error of "An error occurred while validating input parameters: Microsoft.OData.ODataException: The parameter 'ReassignPrinciple' in the request payload is not a valid parameter for the operation 'SetBusinessSystemUser'.
I've verified the values are the same for both calls. I'm obviously missing something here and just not seeing the difference.
Postman call
{{webapiurl}}/systemusers({{systemuserid}})/Microsoft.Dynamics.CRM.SetBusinessSystemUser
{"BusinessUnit": {"businessunitid": "{{targetbusinessunit}}","@odata.type": "Microsoft.Dynamics.CRM.businessunit"},"ReassignPrincipal": {"systemuserid": "{{systemuserid}}","@odata.type": "Microsoft.Dynamics.CRM.systemuser"}}
test app code:
JObject businessUnit = JObject.Parse(@"{businessunitid: '" + businessUnitId + @"', '@odata.type': 'Microsoft.Dynamics.CRM.businessunit' }");
JObject reassignPrinciple = JObject.Parse(@"{systemuserid: '" + systemUserId + @"', '@odata.type': 'Microsoft.Dynamics.CRM.systemuser' }");JObject bodyJson = new JObject()
{
{"BusinessUnit", businessUnit },
{"ReassignPrinciple", reassignPrinciple }
};var stringContent = new StringContent(bodyJson.ToString(), System.Text.Encoding.UTF8, "application/json");
stringContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");var response = await _httpClient.PostAsync($"systemusers({systemUserId})/Microsoft.Dynamics.CRM.SetBusinessSystemUser", stringContent);
test app body string:
"{\r\n \"BusinessUnit\": {\r\n \"businessunitid\": \"a450c60b-345c-eb11-a812-000d3a8a8e8c\",\r\n \"@odata.type\": \"Microsoft.Dynamics.CRM.businessunit\"\r\n },\r\n \"ReassignPrinciple\": {\r\n \"systemuserid\": \"51ca36a1-600e-eb11-a814-000d3a8dfcac\",\r\n \"@odata.type\": \"Microsoft.Dynamics.CRM.systemuser\"\r\n }\r\n}"
Any help is appreciated. Thanks in advance.
Found the error. The object is "ReassignPrincipal" not "ReassignPrinciple".