david.bowerman | 2019-08-29 16:12:14 UTC | #1
I am running into an issue when trying to update/add a location to a user. I am not quite understanding that the error is trying to tell me. The Patch User function only requires the name for the location according to the Schema.
If I try to assign the ID, I can do so for the location but not for the LocationDefinition (readonly). But I receive the same response.
I am receiving the following error: {"status":400,"code":"general.bad.request","message":"Validation error(s): [API Exception 400:\"Bad Request\" : Illegal value for field: 0, Reason: locationId]","messageParams":{"fieldName":"0","errorCode":"GENERALBADREQUEST"},"contextId":"8f6042a8-6233-48d2-a7ad-1f73c3dd0ed1","details":[],"errors":[]} profile updated
This is the location being added: Locations from Builder class Location { Id: FloorplanId: Coordinates: Notes: LocationDefinition: class LocationDefinition { Id: Name: Syracuse, NY EmergencyNumber: Address: AddressVerified: State: Notes: Version: Path: ProfileImage: FloorplanImage: SelfUri: }
private static void UpdateUserProfile(UsersApi usersApi, LocationsApi locationsApi, User userProfile, User mgrProfile, User modelProfile)//Update user profile with manager ID and location { var locations = LocationListBuilder(usersApi, locationsApi, modelProfile); Console.WriteLine("Locations from Builder "+locations[0]); UpdateUser updateBody = new UpdateUser() { Locations = locations, Manager = mgrProfile.Id, Version = userProfile.Version }; Console.WriteLine("UpdateUserBody: "+updateBody); try {usersApi.PatchUser(userProfile.Id, updateBody);} catch (PureCloudPlatform.Client.V2.Client.ApiException e){ Console.WriteLine(e.ErrorContent); } Console.WriteLine("profile updated"); }
private static List<Location> LocationListBuilder(UsersApi usersApi, LocationsApi locationsApi, User modelProfile){ var modelLocation = modelProfile.Locations[0]; var getLocation = locationsApi.GetLocation(modelLocation.LocationDefinition.Id); List<Location> locations = new List<Location>(); LocationDefinition locationDefinition = new LocationDefinition(){ Name = getLocation.Name
}; Location location = new Location(){ LocationDefinition = locationDefinition, }; Console.WriteLine("getLocation details: "+getLocation); Console.WriteLine("Location for new user: "+location); Console.WriteLine("Locations Count from model: "+modelProfile.Locations.Count); Console.WriteLine("Location from model"+modelLocation); locations.Add(location); return locations; }
tim.smith | 2019-08-30 13:40:53 UTC | #2
Based on the resource's documentation (PATCH /api/v2/users/{userId} and the error message, I'm guessing you need to specify locations[x].id
But if that's not working, please open a case with PureCloud Care to investigate as the documentation isn't correct if that's not working.
david.bowerman | 2019-08-30 14:39:50 UTC | #3
Thank you, Tim. Even setting that field returns the same error. I will open a ticket with Care.
david.bowerman | 2019-09-05 13:30:53 UTC | #4
Response from Care was that the functionality is not implemented at this time and to use the legacy Connect-API to perform the update.
Becky_Powell | 2019-09-05 15:49:52 UTC | #5
Hi David,
Can you please share your ticket number with me so that I can follow up?
Thanks so much, Becky
david.bowerman | 2019-09-05 15:55:20 UTC | #6
Becky, my case number is: 0002616025
tim.smith | 2019-09-05 18:58:27 UTC | #7
For anyone browsing this post in the future, the answer from Care is incorrect. Usage of non-public APIs is never allowed as they can, and will, change and be removed entirely over time without any warning.
system | 2019-10-06 19:04:58 UTC | #8
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5906