I'm trying to create new content page from confluence REST api.
Any page created with REST API show up in old editor view. I have tried editor2 option instead of storage and also i tried with metadata(Example), but no luck.
Is there any solution by which i can create page in new editor (v2) from REST API of confluence.
Found this example on Atlassian.net and it works for me:
curl -u 'user:apitoken' -H 'content-type: application/json' \
'https://hello.atlassian.net/wiki/rest/api/content' \
-d '{
"type": "page",
"title": "Page created via API",
"space": {
"key": "TEST"
},
"body": {
"storage": {
"value": "<h1>Test page</h1>",
"representation": "storage"
}
},
"metadata": {
"properties": {
"editor": {
"value": "v2"
}
}
}
}'
Related
In my pipeline (bash, ubuntu-latest) i want to add into already created library a variable (last git commit hash) is it possible ??
Documentation not telling too much about it
You could use this API to update the variable group: https://learn.microsoft.com/en-us/rest/api/azure/devops/distributedtask/variablegroups/update?view=azure-devops-rest-6.0
Use this predefined variable "Build.SourceVersion" to get the latest commit ID: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
Bash script:
curl --location --request PUT 'https://dev.azure.com/{OrgName}/{ProjName}t/_apis/distributedtask/variablegroups/{variablegroupsID}?api-version=7.0' \
--header 'Authorization: Basic {Base64PAT}=' \
--header 'Content-Type: application/json' \
--data-raw '{
"variables": {
"test": {
"value": "$(Build.SourceVersion)"
}
},
"id": 5,
"type": "Vsts",
"name": "1013",
"description": "",
"createdBy": {
"displayName": "{displayName}",
"id": "{id}",
"uniqueName": "{uniqueName}"
},
"createdOn": "2022-10-13T07:41:40.3066667Z",
"modifiedBy": {
"displayName": "{displayName}",
"id": "{id}",
"uniqueName": "{uniqueName}"
},
"modifiedOn": "2022-10-13T07:41:40.3066667Z",
"isShared": false,
"variableGroupProjectReferences": [
{
"projectReference": {
"id": "{Proj id}",
"name": "{Proj Name}"
},
"name": "1013",
"description": ""
}
]
}'
Variable group sample:
Running the script via Azure Pipeline (bash, ubuntu-latest)
Result:
Update1
Im trying to make this api POST request to view.publish endpoint on slack api
As the documentation explains, im using the token and user_id in params, but i dont know what do i need to do with the view param
i set "application/json;charset=UTF-8" as content-type in the headers and on the body the JSON of the payload i want to publish:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a section block with a button."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me",
"emoji": true
},
"value": "click_me_123",
"url": "http://scoreboard-azureslackbot-salvosoftware.s3-website.us-east-2.amazonaws.com/",
"action_id": "button-action"
}
}
]
}
This error is displayed when i make that api call:
{
"ok": false,
"error": "invalid_arguments",
"response_metadata": {
"messages": [
"[ERROR] failed to match all allowed schemas [json-pointer:/view]",
"[ERROR] must provide an object [json-pointer:/view]",
"[ERROR] must provide an object [json-pointer:/view]"
]
}
}
Documentation says that view must be a JSON-encoded string
Also this warning is displayed in the body tab:
This answer is from Aubrey, support team in slack.
No params needed.
In the Authorization tab you need beared authorization.
On the body you need to set is as raw -> JSON and this would be your JSON:
{
"user_id": {{YOUR_USER_ID}},
"view": {
"type": "home",
"blocks": [
{
{{YOUR_PAYLOAD}}
}
]
}
}
It helped me basing on this CURL command
curl -L -X POST 'https://slack.com/api/views.publish' \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer {{YOUR TOKEN}}' \
--data-raw '{
"user_id": {{YOUR USER ID}},
"view": {
"type": "home",
"blocks": [{
{{YOUR PAYLOAD}}
}]
}
}'
My problem is that when I want to update an intent via API DIALOGFLOW V1 it returns Unknown Error, BUT I can list and create the intent via API V1, here is my code for the update:
url : https://api.dialogflow.com/v1/intents/f5eedaaa-f7d1-4e4e-b1fa-6aa66c94ca6f?v=20150910
method : PUT
DATA : {"id":"f5eedaaa-f7d1-4e4e-b1fa-6aa66c94ca6f","name":"FORDEBUG","auto":false,"contexts":[],"responses":[{"resetContexts":false,"affectedContexts":[],"parameters":[],"messages":[{"type":0,"condition":null,"speech":["KOKOKOOOKK","KOJKFKF"]}],"defaultResponsePlatforms":[],"speech":[]}],"priority":500000,"webhookUsed":false,"webhookForSlotFilling":false,"fallbackIntent":false,"events":[],"userSays":[{"id":"d891eb29-7233-4f47-901c-751cbde5fff4","data":[{"text":"KOKOK","userDefined":false}],"isTemplate":false,"count":0,"updated":0,"isAuto":false},{"id":null,"data":[{"text":"FJFLFOPF"}]}],"followUpIntents":[],"liveAgentHandoff":false,"endInteraction":false,"conditionalResponses":[],"condition":null,"conditionalFollowupEvents":[],"templates":[]}
and here is the return that I have :
{
"id": "e5bf8ebf-f5e6-4568-8237-f69dcef6f5db",
"timestamp": "2021-06-07T16:53:36.748Z",
"lang": "en",
"status": {
"code": 400,
"errorType": "bad_request",
"errorDetails": "Unknown error errorid=0a4ffdc6-907a-4049-965d-509490bb428e"
}
}
Unfortunately Dialogflow V1 is already deprecated last May 31, 2020 and no further operations can be performed. It is suggested to migrate to Dialogflow V2 so you can continue using the service.
We are extending the V1 API shutdown deadline to May
31st, 2020. Migrate to the V2 API as described here.
If you use Dialogflow exclusively for Actions on Google, you don't
need to migrate your agent to the V2 API. However, note the following
changes:
The Dialogflow simulator will show responses in the V2 format and the
"Copy curl" button will generate requests in the V2 format. This
should have no impact on the functionality of the Actions on Google
simulator.
You will no longer be able to call API methods for the V1
intents and entities resources. You will still be able to modify your
agent using the Dialogflow Console.
Once you have migrated to V2, you can update an intent by batch or per intent.
EDIT 20210609
Here are the request body and call using curl. I'm not knowledgeable in php, but I suppose you can convert this to curl php.
But I assume that the content of the json will go to data:, the endpoint used in the curl command will be url: and method: will be either PATCH (for single intent) or POST (for batch intent update).
Updating a single intent using request_patch.json
{
"name":"projects/your-project-id/agent/intents/your-intent-id",
"displayName":"Image please",
"trainingPhrases":[
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show an image"
}
]
},
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show me an image"
}
]
},
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show me an image please"
}
]
}
]
}
Curl command:
curl -X PATCH -H "Content-Type: application/json" \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
https://dialogflow.googleapis.com/v2/projects/your-project-id/agent/intents/your-intent-id \
-d #request_patch.json
Successful response:
{
"name": "projects/your-project-id/agent/intents/your-intent-id", "displayName": "Image please",
"priority": 500000
}
Updating batch intents using request_batch.json
{
"intentBatchInline":{
"intents":[
{
"name":"projects/your-project-id/agent/intents/your-intent-id",
"displayName":"Image please",
"trainingPhrases":[
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show an image"
}
]
},
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show me an image"
}
]
},
{
"type":"EXAMPLE",
"parts":[
{
"text":"Show me an image please"
}
]
}
]
}
]
}
}
Curl command:
curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
POST https://dialogflow.googleapis.com/v2/projects/your-project-id/agent/intents:batchUpdate \
-d #request_batch.json
Successful response:
{
"name": "projects/your-project-id/operations/operation-id-here",
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.dialogflow.v2.BatchUpdateIntentsResponse",
"intents": [
{
"name": "projects/your-project-id/agent/intents/your-intent-id",
"displayName": "Image please",
"priority": 500000
}
]
}
}
I'm just strating with RabbitMQ and I try to send a json payload to it. Unfortunately I'm getting error:
{"error":"bad_request","reason":"payload_not_string"}
I read somewhere that I need to use "content_type": "application/json" but that has not helped either.
This is the body I'm trying to send:
{
"properties": {
"delivery_mode": 2,
"content_type": "application/json"
},
"routing_key": "git",
"payload": {
"action": "created",
"comment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
"id": 11056394
}
},
"payload_encoding": "string"
}
And the full curl:
curl -i -X POST \
-H "Content-Type:application/json" \
-H "Authorization:Basic Z3Vlc3Q6Z3Vlc3Q=" \
-d \
'{
"properties": {
"delivery_mode": 2,
"content_type": "application/json"
},
"routing_key": "git",
"payload": {
"action": "created",
"comment": {
"url": "https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394",
"id": 11056394
}
},
"payload_encoding": "string"
}' \
'http://localhost:8090/api/exchanges/%2f/amq.topic/publish'
Is it possible to send the json payload at all? I was thinking of sending Github webhooks to one of the queues.
The RabbitMQ team monitors this mailing list and only sometimes answers questions on StackOverflow.
The error you see is correct, your payload is not a string. I had to reproduce this and re-visit the HTTP API docs for this to become clear.
The value you are passing to the payload key in your JSON is more JSON - in order for it to be a string, you must escape it correctly and pass it like this:
$ curl -4vvv -u guest:guest -H 'Content-Type: application/json' localhost:15672/api/exchanges/%2f/amq.topic/publish --data-binary '{
"properties": {
"delivery_mode": 2,
"content_type": "application/json"
},
"routing_key": "git",
"payload":"{\"action\":\"created\",\"comment\":{\"url\":\"https://api.github.com/repos/baxterthehacker/public-repo/comments/11056394\",\"id\":11056394}}",
"payload_encoding": "string"
}'
The other alternative is to base-64 encode the JSON from GitHub and pass that as the payload - you won't have to escape anything if you do that.
I'm trying to create an index within a set under a specific namespace, but am unsure how to do it.
My resources have this as an HTTP example:
POST /example/v1/index/{namespace}/{set}/{indexName}
and for an example input:
{
"fields": [
{ "indexField": "firstName", "indexReverseOrder": true },
{ "indexField": "lastName" }
],
"options": {
"isUnique": true
}
}
this consumes
application/json;charset=UTF-8
but when I write this out as
curl -X POST exampleurl.com/example/v1/index/example_namespace/example_set/example
set -d " {
"fields": [
{ "indexField": "firstName", "indexReverseOrder": true },
{ "indexField": "lastName" }
],
"options": {
"isUnique": true
} }" -H "Content-type : application/json;charset=UTF-8"
I get the following HTTP status code
HTTP/1.1 415 Unsupported Media Type
Can anyone explain to me what's going on and how I might fix this? Also, let me know if you don't have enough information about the API to understand it, thanks!
EDIT:
As some sort of a reference, for this API when I create a set in a namespace I do:
curl -X POST http://exampleurl.com/example/v1/store/example_namespace -d "example_set" -H "Content-type: application/json;charset=UTF-8"
and this is successful. I thought indexes would be similar to this, but apparently not.
The error is due to the bash shell misinterpreting the double quotes before the json
curl -X POST exampleurl.com/example/v1/index/example_namespace/example_set/example
set -d " {
"fields": [
{ "indexField": "firstName", "indexReverseOrder": true },
{ "indexField": "lastName" }
],
"options": {
"isUnique": true
} }" -H "Content-type : application/json;charset=UTF-8"
should be:
curl -X POST exampleurl.com/example/v1/index/example_namespace/example_set/example
set -d ' {
"fields": [
{ "indexField": "firstName", "indexReverseOrder": true },
{ "indexField": "lastName" }
],
"options": {
"isUnique": true
} }' -H "Content-type : application/json;charset=UTF-8"
The difference is the single quotes encapsulating the json. The bash shell will give an error in trying to execute the command.
You have a typo in your media type:
application/json;charset=UTF=8
Should be:
application/json;charset=UTF-8