I am trying to perform this curl request
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {BEARER_TOKEN}' \
--data-raw '{
"accountEnabled": true,
"displayName": "displayName-value",
"mailNickname": "mailNickname-value",
"userPrincipalName": "test666#mytennant.com",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "password"
}
}'
I keep getting
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"date": "2020-10-23T14:01:06",
"request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c",
"client-request-id": "caf9e0be-88fc-4a4e-a6eb-fed1ccedb90c"
}
}
}
I have the following permissions set on the app registration
Can someone please help me figure out what's wrong here?
Based on the error you are provided it seems to be you are not having right permission to create the user.
In the token, you are missing the permissions, so before making the graph request you need to have the token with
User.ReadWrite.All, Directory.ReadWrite.All.
I made the below request, without having the required permission then I received the same error as you can see below
Then later I added the permissions and requested for the new token, then made the graph call. Now I was successfully able to create the user
Curl
curl --location --request POST 'https://graph.microsoft.com/v1.0/users' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data-raw '{ "accountEnabled": true, "displayName": "displayName-value", "mailNickname": "mailNickname-value", "userPrincipalName": "upn-value1#xx.live", "passwordProfile" : { "forceChangePasswordNextSignIn": true, "password": "xx#123" } }'
Related
I am trying to build a simple Logic App in Azure, that sends an email with a zip attachment using cURL from a Linux VM.
In the Logic App, without the attachment it is working fine.
But it breaks once Attachment is configured.
JSON schema, When a HTTP request is received:
{
"properties": {
"Attachments": {
"type": "array"
},
"cc": {
"type": "string"
},
"from": {
"type": "string"
},
"html": {
"type": "string"
},
"subject": {
"type": "string"
},
"to": {
"type": "string"
}
},
"type": "object"
}
Config for Outlook Send an email v2, Logic App, Azure
Commands to send email from Linux VM:
# create attachment
echo "abcd" > test.txt
zip test.zip test.txt
# curl to send json to azure logic app, with attachment
curl -vvv --request POST \
--header 'Content-Type: application/json' \
--url 'https://prod-21.southeastasia.logic.azure.com:443/workflows/xxx/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xxx' \
--data '{"from": "xxx#outlook.com", "cc": "xxx#outlook.com, "Attachments": [{ "Content-Type": "BASE64_ENCODED_CONTENT", "Name": "test.zip" }], "to": "xxx#outlook.com", "subject": "Hello, World!", "html": "Hey, test email." }'
Error message from the Run History, Logic App, Azure
Full error from the log:
{
"status": 400,
"message": "Parameter 'Attachment Content' cannot be null or empty.\r\nclientRequestId: 40d2dc9c-549b-4608-xxxxxxxxxxxxxxx",
"error": {
"message": "Parameter 'Attachment Content' cannot be null or empty."
},
"source": "office365-sea.azconn-sea.p.azurewebsites.net"
}
Would like to know how to handle the attachment on this scenario. Any documentation would be helpful as well.
Thank you.
Would be also interested in this topic!
Did you try to use --form instead of --data? Or do you already have a solution for this?
I also tried to specify the "Attachments" property in logic apps as:
"properties": {
"Attachment": {
"contentEncoding": "base64",
"contentMediaType": "image/png",
"type": "string"
},
}
...
While trying to use the CluedIn REST API command to update provider configuration details the response is the html code for the CluedIn webpage (error) without any details as to why. When checking the values which should be updated, they are not.
What is the correct process to update provider configuration variables via the REST API?
If you work with CluedIn 3.2.4, you can update the integration configuration from the "Authentication" tab:
If you are on earlier 3.x versions, you have to do two steps: get the provider configuration, and update the provider configuration.
Before you start, please get an authentication token:
curl --location --request POST
'https://orgname.domain/auth/connect/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=admin#domain' \
--data-urlencode 'password=yourstrongpassword' \
--data-urlencode 'client_id=int' \
--data-urlencode 'grant_type=password'
Example response:
{
"access_token": "...",
"expires_in": 3600,
"token_type": "Bearer",
"refresh_token": "...",
"scope": "offline_access openid profile ServerApiForUI SpecificBlobApi"
}
Now, get the provider configuration.
First, you need the configuration ID. That's the last part of the URL when you open the configured integration in the browser. I.e. https://orgname.domain/admin/configuration/integration-guid/youneed-this-guid.
Now run:
curl --location --request GET 'https://orgname.domain/api/api/configuration/providers?id=your-integration-configuration-guid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your-auth-token'
Expected response:
{
"ProviderId": "...",
"Name": "...",
"Guide": null,
"PlanLevel": 1,
"Configuration": {
"Authorization": "...",
"firstTime": false,
"LastCrawlFinishTime": "2021-10-27T08:38:51.9620662+00:00",
"lastCursor": {}
},
"Active": true,
"OrganizationId": "...",
"Type": "Cloud",
"helperConfiguration": {
"ClientId": "...",
"ClientSecret": "..."
},
"CodeName": "...",
"UserId": "...",
"SourceQuality": 5,
"Source": "",
"AutoSync": false,
"AuthType": null,
"Id": "...",
"UserName": "admin#domain",
"AuthTypes": null,
"AccountId": "",
"AccountDisplay": "Integration Name",
"EntityId": "...",
"SupportsConfiguration": true,
"SupportsWebhooks": false,
"SupportsAutomaticWebhookCreation": true,
"FailingAuthentication": false,
"Stats": {
"Name": "Provider Stats",
"ProviderStatus": {
"Crawling": {
"$type": "CluedIn.Server.WebApi.Models.Providers.ProviderStatusCrawlInfo, CluedIn.Server.WebApi",
"TaskCount": 0,
"TasksCompletedCount": 0,
"TasksCompletedPerMinute": 0.0,
"TasksFailedCount": 0,
"TasksQueuedCount": 0,
"ExpectedTasksCount": 0
},
"Processing": null,
"State": "Crawling",
"Summary": null
},
"ProviderId": "...",
"ConfigurationId": "...",
"OrganizationId": "..."
},
"Status": {
"NextExecution": "2021-10-27T12:38:00Z"
},
"WebhookManagementEndpoints": null,
"Webhooks": null,
"DataStatistics": {
"EntityTypeStatistics": []
},
"ExpectedData": 0,
"ExpectedStatistics": null,
"ExpectedTaskCount": 0,
"ExpectedTime": "00:00:00",
"CreatedDate": "2021-07-28T08:37:50.7865925+00:00"
}
In this response, change the helperConfiguration and Put it back in a response body:
curl --location --request PUT 'https://orgname.domain/api/api/v2/organization/Providers?accountId=&providerId=your-configuration-guid' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer your-access-token' \
--data-raw 'your-updated-json'
Expected response:
{
"AccountDisplay": "...",
"AutoSync": false,
"Source": "",
"SourceQuality": 5,
"Id": "...",
"appUrl": "",
"SupportsWebHooks": false,
"SupportsAutomaticWebhookCreation": true,
"SupportsConfiguration": true,
"helperConfiguration": {
"ClientId": "...",
"ClientSecret": "...",
"Authorization": "...",
"firstTime": false,
"LastCrawlFinishTime": "01/01/0001 00:00:00 +00:00",
"lastCursor": ""
},
"configurationDictionary": {
"ClientId": "...",
"ClientSecret": "...",
"Authorization": "...",
"firstTime": false,
"LastCrawlFinishTime": "01/01/0001 00:00:00 +00:00",
"lastCursor": ""
}
}
So we have a People schema and a Project schema, both of which are used on separate pages where you can filter the results. We are at a point where we are realising that we need to filter something like current projects, but on the PEOPLE list. However the data for that lives in Projects, and we are having trouble in finding a clean way to cross-reference the schemas and filter on a computed value.
Eg. Filter the list of people by projects that are currently active (ie. the current time).
There doesn't seem to be any way to do this in ES - my current option is stitching these together in the front-end and doing another "filter" there, but that feels hacky.
Displaying the data on the People list is no issue, it's the filtering.
Has anyone run into this situation before, and how did you resolve it? Appreciate any insight. THanks!
If I understand things correctly, you have two separate indices for people and projects.
Unfortunately, the only way to do things right is to denormalize your data in Elasticsearch and include projects on the people list.
You could also use Parent-child relationships.
Please read this excellent blog posts:
https://rockset.com/blog/can-i-do-sql-style-joins-in-elasticsearch/
and then Parent-Child Modeling in Elasticsearch https://blog.mimacom.com/parent-child-elasticsearch/
The previous link show examples in ElasticSearch 5.6 and 6. I'll provide examples that works in ES 7:
According to the post:
There are four common approaches to managing data in Elasticsearch:
Denormalization, Application-side joins, Nested objects, Parent-child relationships
One-to-one relationships: Object mapping
One-to-many relationships: Nested documents and the parent-child model
Many-to-many relationships: Denormalizing and application-side joins
Challenges with Parent-Child Relationships
Queries are more expensive and memory-intensive because of the join operation. There is an overhead to parent-child constructs, since they are separate documents that must be joined at query time. Need to ensure that the parent and all its children exist on the same shard. Storing documents with parent-child relationships involves implementation complexity.
I'll provide an example ready to execute on ES 7
curl -XDELETE "localhost:9200/project"
curl -XPUT "localhost:9200/project" \
-H 'Content-Type: application/json' \
-d'{
"settings": {
"number_of_shards": 1, "number_of_replicas": 0
},
"mappings": {
"properties": {
"project": { "type": "text" },
"people": { "type": "text" },
"active": { "type": "boolean" },
"project_relations": {
"type": "join",
"relations": {
"project": "people"
}
}
}
}
}'
curl -XPUT "localhost:9200/project/_bulk" \
-H 'Content-Type: application/json' \
-d'
{"index":{"_id":1}}
{"name":"ElasticSearch upgrade","project_relations":{"name":"project"}, "active": true}
{"index":{"_id":2}}
{"name":"Website","project_relations":{"name":"project"}, "active": true}
{"index":{"_id":3}}
{"name":"SQL Server migration","project_relations":{"name":"project"}, "active": false}
'
curl -XPUT "localhost:9200/project/_doc/4?routing=1" \
-H 'Content-Type: application/json' \
-d'
{"people":"Evaldas Buinauskas","project_relations":{"name":"people","parent":1}}
'
curl -XPOST "localhost:9200/project/_doc/5?routing=1" \
-H 'Content-Type: application/json' \
-d'
{"people":"xynon","project_relations":{"name":"people","parent":1}}
'
The routing must correspond to the project id
curl -XPOST "localhost:9200/project/_doc/6?routing=2" \
-H 'Content-Type: application/json' \
-d'
{"people":"Harry scherer","project_relations":{"name":"people","parent":2}}
'
curl -XPOST "localhost:9200/project/_doc/7?routing=2" \
-H 'Content-Type: application/json' \
-d'
{"people":"Darrel Simon","project_relations":{"name":"people","parent":2}}
'
curl -XPOST "localhost:9200/project/_doc/8?routing=3" \
-H 'Content-Type: application/json' \
-d'
{"people":"Juan Carlos Alafita","project_relations":{"name":"people","parent":3}}
'
Search people working on ElasticSearch upgrade and project is active
curl -XGET "localhost:9200/project/_search" \
-H 'Content-Type: application/json' \
-d'
{
"query": {
"has_parent": {
"parent_type": "project",
"query": { "bool": {"must": [ {"match": { "active": true } }, {"match": { "name": "ElasticSearch upgrade" } } ] }}
}
}
}' | jq
Results:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "project",
"_type": "_doc",
"_id": "4",
"_score": 1,
"_routing": "1",
"_source": {
"people": "Evaldas Buinauskas",
"project_relations": {
"name": "people",
"parent": 1
}
}
},
{
"_index": "project",
"_type": "_doc",
"_id": "5",
"_score": 1,
"_routing": "1",
"_source": {
"people": "xynon",
"project_relations": {
"name": "people",
"parent": 1
}
}
}
]
}
}
Search people working on SQL Server migration and project inactive
curl -XGET "localhost:9200/project/_search" \
-H 'Content-Type: application/json' \
-d'
{
"query": {
"has_parent": {
"parent_type": "project",
"query": { "bool": {"must": [ {"match": { "active": false } }, {"match": { "name": "SQL Server migration" } } ] }}
}
}
}
' | jq
curl -XGET "localhost:9200/project/_search" \
-H 'Content-Type: application/json' \
-d'
{
"query": {
"has_parent": {
"parent_type": "project",
"query": { "match_all": {} }
}
}
}'
I have simple bot ,I want to set a greating text and add three buttons to it
something like this.
Welcom Johhn to man utd'
-first button
-second button
-third button
here is what I have tried
$ curl -X POST -H "Content-Type: application/json" -d '{
"greeting": [
{
"locale":"default",
"text":"Hello {{user_first_name}}! Welcome to Man utd"
message: {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [{
"title": "Hi , thanks for messaging videommerce",
"buttons": [{
"type": "postback",
"title": "Select video purpose",
"payload": "purpose"
}, {
"type": "postback",
"title": "How to create video",
"payload": "create"
},{
"type": "web_url",
"url": "https://www.videommerce.com/",
"title": "Talk to us directly (moving to Customerly live chat)"
}],
}]
}
}
}
}
]
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=token"
What do I need to change to get what I want?
The greeting webhook does not have the attachment property, as you can see here: documentation.
So, your greeting will work only with the parameters locale and text:
$ curl -X POST -H "Content-Type: application/json" -d '{
"greeting": [
{
"locale":"default",
"text":"Hello {{user_first_name}}! Welcome to Man utd"
}]}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=token"
If you want to show some buttons to the user, the correct way is to call another webhook, after you send the greeting one, the persistent-menu, as described here.. This code will do the work:
curl -X POST -H "Content-Type: application/json" -d '{
"setting_type" : "call_to_actions",
"thread_state" : "existing_thread",
"call_to_actions":[
{
"type":"postback",
"title":"Help",
"payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_HELP"
},
{
"type":"postback",
"title":"Latest Posts",
"payload":"DEVELOPER_DEFINED_PAYLOAD_FOR_LATEST_POSTS"
},
{
"type":"web_url",
"title":"View Website",
"url":"http://yoursite.com/"
}
]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=PAGE_ACCESS_TOKEN"
Hello Stackoverflower,
I'm setting up buddy-http-api using docker.
After docker container launch is done, I ssh to docker container for testing API.
I run:
curl http://localhost:9123/api/account -X POST -H "Content-Type: application/json" \
-H "Accept: application/json" \
-d "{ \
\"username\": \"user2#ab.com\", \
\"password\": \"12345678\", \
\"email\": \"thanh.nguyen2891#gmail.com\"\
}"
I got:
Unauthorized
I'm not sure how to put it into authenticate. I have read http://buddycloud.com/api#create-post
logs:
{
"req": {
"url": "/api/account",
"headers": {
"user-agent": "curl/7.35.0",
"host": "localhost:9123",
"accept": "*/*",
"content-type": "application/json; charset=utf-8",
"content-length": "45"
},
"method": "POST",
"httpVersion": "1.1",
"originalUrl": "/api/account",
"query": {}
},
"res": {
"statusCode": 401
},
"responseTime": 1,
"level": "info",
"message": "HTTP POST /api/account"
}
Thanks in advance !