Can't add group attribute via Keycloak Admin Rest API - keycloak

I'm sending a request to PUT /{realm}/groups/{id} to add a group attribute to an existing group.
The body of PUT request looks like this:
{"attributes":{"id":123}}
It's failing and returning 500 error.
The documentation is not clear about the format of "Map" schema. https://www.keycloak.org/docs-api/6.0/rest-api/#_grouprepresentation shows "attributes" field type is "Map" but it's not defined. I tried several formats, like:
{"attributes":[{"id":123}]}
{"attributes":{"key":"id","value":123}}
{"attributes":[{"key":"id","value":123}]}
but none of them is working.
What is "Map" schema and why is my request returning 500?

You can create group along with attribute, request body will be
{"name":"myGroup","attributes":{"attr1":["value1"]}}
with two attributes it should be something like this
{"name":"mygroup","attributes":{"attr2":["value2"],"attr1":["value1"]}}"

Related

How to define id in POST request using Ravendb

Hello there
I'm having a trouble when I try to insert a document into a Ravendb Server which is running in my other computer. I can retrieve documents easily, but when I try to use REST API with POST request I get this error
"System.ArgumentException","Message":"Query string value 'id' must have a non empty value","Error":"System.ArgumentException: Query string value 'id' must have a non empty value
even though I have my Id defined like this:
{
"id":"adawd",
"name":"genereicname",
"password":"something"
}
Originally I'm making a flutter application but currently I'm just testing the API with Postman.
I messed around with id's (String, int) tried to leave it empty but no luck, does anyone know how to define Id for raven db to send me that sweet 200 response code...
According to the documentation you should use PUT to upload a new document or modify an existing one.
See: https://ravendb.net/docs/article-page/5.2/csharp/client-api/rest-api/document-commands/put-documents

Proper multi-id syntax when using the custom_file_ids[] query parameter for the CLIO API "contacts" endpoint

What is the correct API syntax for using the custom_file_ids[] query parameter to specify multiple fields (but not all) in the CLIO API contacts result set? I need to specify multiple custom fields. I can get it to work for a single field, but not multiple fields at the same time.
Specifically, how do I specify and delimit the multiple fields? I have tried the following:
custom_file_ids[]=1234567,2345678
custom_file_ids[]=[1234567,2345678]
custom_file_ids[]=(1234567,2345678)
custom_file_ids[]={1234567,2345678}
custom_file_ids[]=1234567:2345678
The API documentation at https://app.clio.com/api/v4/documentation is silent on the list syntax that it expects.
Below is one specific API call I tried (both the actual URL-encoded call, and a decoded one for clarity) using a simple comma-delimited list, but which only returns custom field data for the first ID in the list--not the second. If I enclose the ID list in any kind of brackets (per above), the endpoint returns a 404 error.
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567%2C2345678&custom_field_values[4529224]=true&fields=id%2Cname%2Cprimary_address%2Cprimary_work_address%2Cis_client%2Ctype%2C%20primary_email_address%2Cprimary_phone_number%2Ccustom_field_values%7Bid%2Cfield_type%2Cfield_name%2Cvalue%2Ccustom_field%7D
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567,2345678&custom_field_values[4529224]=true&fields=id,name,primary_address,primary_work_address,is_client,type,primary_email_address,primary_phone_number,custom_field_values{id,field_type,field_name,value,custom_field}
Try:
custom_file_ids[]=1234567&custom_file_ids[]=2345678
I was able to do this with Contacts Custom Fields by putting custom_field_id[] on the URL as many times as you have IDs.
I hope this helps.

Salesforce API - Using Compound fields. (Cannot deserialize instance of MailingAddress from VALUE_STRING)

Using REST API for Salesforce, I am trying to insert/update a contact into my business org where 'MailingAddress' is one of the fields with some set data, though in response I am getting this error message 'Cannot deserialize instance of MailingAddress from VALUE_STRING', the same response also resulting in 'OtherAddress'.
To my understanding, I think this is due to the reason that 'MailingAddress' and 'OtherAddress' are not actual fields that contains some String data, rather they take a dynamic address which resulting in filling up all other related fields like - 'MailingCity, MailingStreet, etc'.
So I have 2 questions:
1. How can I set 'MailingAddress' and 'OtherAddress' fields using API parameter only?
2. Is there any manual/documentation for this reference? As I am also having trouble with 'OtherLatitude' and 'OtherLogitude' fields.
Address and geolocation fields are compound fields.
You need to provide the value for the different components of the field, so for example, for MailingAddress you would need to provide MailingStreet, MailingCity, MailingState or MailingStateCode, etc. And for OtherAddress you would provide OtherStreet, OtherCity, etc.
For more information on compound fields: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/compound_fields.htm

How to use scopeDescriptor and subjectTypes in VSTS Graph api groups list query?

I am trying to resolve a particular VSTS group by name to retrieve the identityDescriptor property. Rather than query all groups and filter, I want to leverage the query parameters supported. Looking at VSTS Groups - List API, it supports the additional query parameters scopeDescriptor, and subjectType. However, I keep providing bad values for these parameters.
However, when I specify any combination of these I get 0 results. In addition, as soon as I add a scopeDescriptor, I hit an Microsoft.VisualStudio.Services.Graph.InvalidSubjectTypeException -> HTTP 400 Bad Request.
Questions:
What are examples of expected values for subjectTypes?
Edit 1
subjectTypes are not the actual type, but the subtype that prefixes the subject descriptor. For example -> vssgp,aadgp:
"subjectDescriptor": "vssgp.Dc0NDgzLTzQ1NwOTI5LTI0NTcwNDLTAtMwUy0xLTktMTAtMC0wMjgxNjcxNDU0OS0zMU1MTM3NDI0NS0yMjUzNzA0ODMtE"
What are examples of expected values for scopeDescriptor?
Example query urls:
- Working:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?api-version=4.1-preview.1
- Working subjectTypes:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?subjectTypes=vssgp&api-version=4.1-preview.1
- scopeDescriptor throws:
https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&api-version=4.1-preview.1
https://{account}.vssps.visualstudio.com/_apis/graph/groups?scopeDescriptor=collection&subjectTypes=Microsoft.TeamFoundation.Identity&api-version=4.1-preview.1
You can get the scope descriptors for a project or a collection by making an api request to https://vssps.dev.azure.com/{organization}/_apis/graph/descriptors/{Id}(replace id with projectId if you want to get the scope descriptor for a project and so on).
For example if you want to get the scope descriptor for a project then simply replace the storage key in the request URL with the project Id and in response you get the scope descriptor. The scope descriptor has the following format scp.(long unique identifier).
P.S: More on how to get descriptors can be found here https://learn.microsoft.com/en-us/rest/api/azure/devops/graph/descriptors/get?view=azure-devops-rest-5.0. Remember storagekey can be substituted with projectid or collectionid to get specific descriptors.
Regarding subjectTypes, it is the group type, such as vssgp, aadgp, you can get it from descriptor value of each group.

Rest API: How should the filter params send to API in case query based on nested resource

I have two entities Properties and Bookings.
I need to know the URL structure in case I'm filtering the properties base on query on bookings.
In my case I need to get the properties which are free (not occupied) at specific date.
Can it be
api/properties/free/{date}
Or
api/properties/bookings?bookingDate!='1-1-2017'
Or
api/properties?bookingDate!='1-1-2017'
it seems for me that the last one is the more appropriate but the filter is on the bookings not on the properties which is not obvious.
The Facebook Graph API has a interesting way of doing nested queries by using a strategy of fields filter.
The fields filter it´s a way of filter specific fields or nested fields of a rouserce. They also create a standard way to inform functions for every selected field like: limit or equal.
Your request would be something like this:
GET /api/properties?fields=bookings{bookingDate.notEqual('1-1-2017')}
For more information about Facebook´s GraphAPI:
https://developers.facebook.com/docs/graph-api/overview/