Been going through the documentation (https://cdn.rawgit.com/rabbitmq/rabbitmq-management/v3.7.9/priv/www/api/index.html)
And did not find a way to publish a message to a queue (not an exchange, a queue) with the HTTP API?
Is that possible?
As much as it might make little sens in a production mindset, it still can be useful for testing purposes.
I basically want to mimic the “Publish message” interface available in the RabbitMQ administration console.
Is this possible somehow?
Note: your question is already answered here: link
RabbitMQ only supports publishing to exchanges. This is a core function of the product. Then, RabbitMQ uses bindings to figure out what queue(s) should receive the message.
You can read about these concepts here.
When you use "Publish message" in the administration console, it uses the default binding and default exchange. From this document:
The default exchange
In previous parts of the tutorial we knew nothing about exchanges, but still were able to send messages to queues. That was possible because we were using a default exchange, which we identify by the empty string ("").
Recall how we published a message before:
channel.basic_publish(exchange='',
routing_key='hello',
body=message)
The exchange parameter is the name of the exchange. The empty string denotes the default or nameless exchange: messages are routed to the queue with the name specified by routing_key, if it exists.
So, in order to appear to publish directly to a queue, the management interface publishes a message to the default exchange (named amq.default or the empty string "") using the queue name as the routing key. You can see this for yourself by enabling the developer tools in your browser and watching the HTTP call made to /api/exchanges/vhost/name/publish when you publish a message to a queue.
In your case, the request will look something like this (use Chrome, and right-click the publish request and "copy as cUrl"):
curl -4vvv -u guest:guest \
'localhost:15672/api/exchanges/%2F/amq.default/publish' \
-H 'Content-Type: text/plain;charset=UTF-8' \
--data-binary '{"vhost":"/","name":"amq.default","properties":{"delivery_mode":1,"headers":{}},"routing_key":"MY-QUEUE-NAME","delivery_mode":"1","payload":"TEST","headers":{},"props":{},"payload_encoding":"string"}'
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
For those interested in Intellij IDEA HTTP Client syntax with an array of ids
[
{"id": "83d6e4dc-0478-42da-8da0-65b508530a43"},
{"id": "08d3e147-79c4-4b91-be7c-b1cc86e21278"}
]
POST http://localhost:15672/api/exchanges/%2F/amqp.myexchange/publish
Authorization: Basic guest guest
Content-Type: application/json
{
"vhost": "/",
"name": "amqp.myexchange",
"properties": {
"delivery_mode": 2,
"headers": {},
"content_type": "application/json"
},
"routing_key": "",
"delivery_mode": "2",
"payload": "[{\"id\":\"83d6e4dc-0478-42da-8da0-65b508530a43\"},{\"id\":\"08d3e147-79c4-4b91-be7c-b1cc86e21278\"}]",
"headers": {},
"props": {
"content_type": "application/json"
},
"payload_encoding": "string"
}
I know this post is quite old, but maybe still get found.
Here is a 3rd party tool that may help in such situations, when you need to publish a message directly into a queue:
https://github.com/bkrieger1991/rabbitcli
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.18\sbin>
C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.18\sbin>curl -i -u guest:guest localhost:15672/api/exchanges/%2F/amq.default/publish -H 'content-type:application/json" -d '{"vhost":"/","name":"amq.default","properties":{"delivery_mode":1,"headers":{}},"routing_key":"TEST,"delivery_mode":"1","payload":"TEST","headers":{},"props":{},"payload_encoding":"string"}'
HTTP/1.1 405 Method Not Allowed
allow: POST, OPTIONS
content-length: 0
content-security-policy: default-src 'self'
date: Fri, 06 Dec 2019 14:03:08 GMT
server: Cowboy
vary: origin
Related
I sent a webhook into open solar via post as below see the api https://developers.opensolar.com/#webhooks. The webhook is in an airtable automation. The issue is when reducing the payload and trigger fields it does not appear to make a to the data recieved in the webhook. I am still receiving data from Models "Project", "Contact" & "Event" despite having removed these from the webhooks trigger fields and payload fields.
Here are the steps I took
First I posted the below webhook into open solar for testing and verified that was the case with GET.
curl "https://api.opensolar.com/api/orgs/:org_id/webhooks/" --request POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"endpoint": "https://somesolar.com/api/", "headers": "{"Authorization": "Token "}", "enabled": true, "debug": false, "trigger_fields":["contact.", "event.", "project."], "payload_fields":["contact.", "event.", "project."]}'
Since there were cases where different payloads were being received by one webhook this caused me errors in the airtable automation using a webhook as a trigger because there were some instances when the payload did not have the fields I was using to update fields in a create new record action.
So I decided to setup 3 webhooks one for each payload type, "contact", "event" and "project". So I updated (and I also deleted and re uploaded the webhook) and sent a new webhook in as below.
curl "https://api.opensolar.com/api/orgs/:org_id/webhooks/" --request POST -H "Content-Type: application/json" -H "Authorization: Bearer " -d '{"endpoint": "https://somesolar.com/api/", "headers": "{"Authorization": "Token "}", "enabled": true, "debug": false, "trigger_fields":["contact."], "payload_fields":["contact."}'
However I am still receiving all 3 payloads triggered by all 3 trigger fields. Does anyone know why or any other steps to troubleshoot? thanks v much!
I'm having trouble setting a Webhook URL for the Cloudflare Stream product. I am receiving an 10012 error when attempting to access the API endpoint.
I'm following the documentation located here: https://developers.cloudflare.com/stream/webhooks/
Here's the example cURL call I make:
curl -X "PUT" "https://api.cloudflare.com/client/v4/accounts/{MY_ACCOUNT}/media/webhook" \
-H 'X-Auth-Key: {MY_AUTH_KEY}' \
-H 'X-Auth-Email: {MY_EMAIL}' \
-d "{\"notification_url\":\"{A_URL}\"}"
The response received is:
{
"result": null,
"success": false,
"errors": [
{
"code": 10012,
"message": "Forbidden"
}
],
"messages": null
}
I'm confident that I am entering the correct authentication key, account ID, etc. It's all copy/pasted from dash.cloudflare.com and have verified that this API key works on other API endpoints.
I submitted a ticket and they replied after they “made some internal configuration changes” and now the webhook API endpoints work flawlessly. Thanks for the quick help, Cloudflare!
I want to create a skype bot and am referring to https://developer.microsoft.com/en-us/skype/bots/docs/api/chat , for authorization the doc refers to https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-protocols-oauth-code/ but it is unclear about the scope to be mentioned for using skype bot apis.
So can anybody tell me how to obtain authorization token for making skype bot rest api calls.
try this
curl -X POST -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id=<your-app-id>&client_secret=<your-app-secret>&grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default' 'https://login.microsoftonline.com/common/oauth2/v2.0/token'
I'm trying to try token access to the skype bot.
I have also tried the above mentioned cURL function in "POSTMAN" but I have this return message:
{
"error": "invalid_request",
"error_description": "AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: 53dcaec0-...\r\nCorrelation ID: d6d650ec...\r\nTimestamp: 2018-01-15 09:53:04Z",
"error_codes": [
90014
],
"timestamp": "2018-01-15 09:53:04Z",
"trace_id": "53dcaec0-...",
"correlation_id": "d6d650ec-..."
}
The following is a header and body structure in POSTMAN:
HEADER
Content_type: application/x-www-url-form-urlencoded
Cache-Control: no-cache
BODY
client_id=&client_secret=&grant_type=client_credentials&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
In BODY I replace the fields client_id and client_secret with the correct codes provided during registration.
Thanks to the availability...
So we have been using the Flowdock Push API for quite some time now. We have been using it to push messages from our Continous Integration server (Electric commander) and it has been working pretty great. It's integrated into a powershell script today.
Now i have been notified that the PUSH API is deprecated and will be removed "some day" along with a refference to the REST API's message feature.
Following the documentation i have been able to add messages from my personal API token directly to the chat. However when i try to add a message to the inbox, with the flow API token, i keep getting 404's
I am using fiddler's compose feature to fiddle (ha!) with the examples from the dox (i have anonymized it a bit):
POST https://api.flowdock.com/MYORGANIZATION/MYFLOW/mesages
User-Agent: Fiddler
Host: api.flowdock.com
Content-Length: 593
Content-Type: application/json
Accept: application/json
{
"flow_token": "MYFLOWS API TOKEN",
"event": "activity",
"author": {
"name": "anttipitkanen",
"avatar": "https://avatars.githubusercontent.com/u/946511?v=2"
},
"title": "Opened pull request",
"thread_id": "WT5yWsIpdvUPxP07lfgQDmLoGQQ",
"external_thread_id": "github:component:pr:42",
"thread": {
"title": "Fix bug in thread API",
"body": "Body with <b>HTML<b> formatting",
"external_url": "https://github.com/flowdock/component/pull/42",
"status": {
"color": "green",
"value": "open"
}
}
}
Raw response is:
HTTP/1.1 404 Not Found
Date: Thu, 08 Oct 2015 10:02:34 GMT
Status: 404 Not Found
Content-Type: application/json
X-Request-Id: ab39438c-07b7-48bf-bde8-c3b29478094d
X-Runtime: 0.007442
Strict-Transport-Security: max-age=31557600
X-Server-Id: 3c4883af38147558374983c6d90b2bb9badb86d4
Vary: Accept-Encoding
Transfer-Encoding: chunked
20
{"message":"Resource not found"}
0
Is the flow_token the API token for my flow? Or is it the dev token i have to sign up for?
This is not meant to work as an application, i just wan't to push the status of builds and deploys to the other developers.
https://www.flowdock.com/api/message-types#/activity
The correct endpoint is https://api.flowdock.com/flows/ORG/FLOW/messages.
The flow_token is a bit confusingly named since it is not the flow API token, instead it is a source's flow_token. In order to get a flow_token to a source, you will need to create an application. Then create a source for it to a certain flow. Easiest way to do this is using the "Tools for testing" section in the application.
Lastly you probably want to use only the "external_thread_id".
I have approximately 250,000 JSON-formatted files, each with one object in it (formatted just how CouchDB likes it with _id). What's the best way to import these into my remote CouchDB server as records?
-I am on a windows xp machine.
-I have internet access but I can't set up a couchDB server on my local machine and have it be WWW accessible (firewall constraints.) so no easy replication.
I would highly suggest that you look into the bulk doc API in the couchdb wiki: http://wiki.apache.org/couchdb/HTTP_Bulk_Document_API
Basically, you make a POST request to /someDatabase/_bulk_docs that looks like this:
{
"docs": [
{ "_id": "awsdflasdfsadf", "foo": "bar" },
{ "_id": "cczsasdfwuhfas", "bwah": "there" },
...
]
}
Just like any other POST request, if you don't include _id properties, couchdb will generate them for you.
You can use this same operation to update a bunch of docs: just include their _rev property. And if you want to delete any of the docs that you are updating, then add a "_deleted": true property to the document.
If you have a json file with your documents and use curl, it could look like:
curl -H "Content-Type: application/json" --data-binary #/home/xxx/data.json https://usr:pwd#host:5984/someDatabase/_bulk_docs/
Cheers.