Discord - Webhook using JSON 400 bad request "embeds" "0" - json

I've trying to learn JSON along with using web hooks. I'm trying to use postman to test my code but I'm getting an error. Anyone have any ideas?
POST /api/webhooks/XXXXXXXXXXXXXXX HTTP/1.1
Host: discord.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: dbb93a2b-fced-8bd6-df89-XXXXXXXXXXX
{
"embeds":
[{
"ticker": "{{ticker}}",
"exchange": "{{exchange}}",
"interval": "{{interval}}",
"date": "{{date}}",
"timenow": "{{timenow}}"
}]
}
error message
{
"embeds": [
"0"
]
}
Discord docs for JSON
https://discord.com/developers/docs/resources/channel#create-message

Related

Routing error with REST API in Clickatell

I am trying to send a SMS using REST API in clickatell.
I tested it using POSTMAN.
I sent the Headers as
POST /rest/message HTTP/1.1
Host: api.clickatell.com
Accept: application/json
Content-Type: application/json
X-Version: 1
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxx
In body
{
"from": ["xxxxxxxxxx"],
"mo": "1",
"text": "Test Message ",
"to": ["xxxxxxxxx"]
}
I get a response as
{
"data": {
"message": [
{
"accepted": true,
"to": "xxxxxxxxxxxxx",
"apiMessageId": "xxxxxxxxxxxxxxxxxxxxxxxxx"
}
]
}
}
But when I check in clickatell account it shows the message is not sent and there is a ROUTING ERROR.
I am getting this error only while using REST API. Using HTTP is works fine.
Can someone help?
You're using MO set to 1, so that means that you are attempting to send from a two-way number. Make sure your two-way number is linked to the REST API integration.

DEVICE_GROUP_NOT_FOUND in iotagent-ul

I'm trying to send measurements using IoT Agent UL2.0.
First, I created a device as follows:
POST /iot/devices HTTP/1.1
Host: localhost:4061
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: application/json
Cache-Control: no-cache
{
"devices": [
{
"device_id": "A6",
"entity_name": "A6",
"entity_type": "E6",
"attributes": [
{ "object_id": "a", "name": "aaa", "type": "text" },
{ "object_id": "b", "name": "bbb", "type": "text" },
{ "object_id": "c", "name": "ccc", "type": "text" }
]
}
]
}
Then I'm trying to send measurements as follows:
POST /iot/d?i=A6&k=A6&d=a|7|b|7|c|7 HTTP/1.1
Host: localhost:7896
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: text/plain
Cache-Control: no-cache
But I'm getting the following error:
{
"name": "DEVICE_GROUP_NOT_FOUND",
"message": "Couldn\t find device group"
}
What the device group is?
Thanks!
I figured out how to solve it.
I just changed config.defaultTransport to HTTP in config.js and used TEF as apikey.
The request that effectively sent measures to Orion was the following:
POST /iot/d?i=A6&k=TEF&d=a|7|b|7|c|7 HTTP/1.1
Host: localhost:7896
Fiware-Service: Empresa1
Fiware-ServicePath: /empresa1
Content-Type: text/plain
Cache-Control: no-cache
I hope this helps somebody.
be careful, you need to configure a service, so that you can use your own API KEY, and that can be done by issuing an HTTP request like this
POST http://130.206.80.40:5371/iot/services
Headers:
{
'Content-Type': 'application/json',
'X-Auth-Token' : '[TOKEN]',
'Fiware-Service': 'openiot',
'Fiware-ServicePath': '/'
}
Payload:
{
"services": [
{
"apikey": "4jggokgpepnvsb2uv4s40d59ov",
"cbroker": "http://0.0.0.0:1026",
"entity_type": "thing",
"resource": "/iot/d"
}
]
}
The previous answer from jose-manuel-cantera is correct. Also, pay attention in the resource field should start with a slash /. I was having the same issue as yours, see this ticket https://github.com/telefonicaid/iotagent-ul/issues/459.

How to Add Labels to Confluence Page via REST

I've been hunting for the correct way to add labels to a confluence page via REST (tags, categories, or whatever they are calling them today)
the documentation simply says "add json to the body" and then shows this example
[{"prefix":"global","name":"label1"},{"prefix":"global","name":"label2"}]
Has anyone successfully done this
You need to POST the JSON body using this endpoint: POST /rest/api/content/{id}/label where the id is the id for the content (page).
Reference: https://docs.atlassian.com/confluence/REST/latest/#content/{id}/label-addLabels
For example:
POST /rest/api/content/{id}/label HTTP/1.1
Host: yourinstance.atlassian.net
Authorization: Basic YaRtsWdg4VzdAzazhib2FyZA==
Content-Type: application/json
Cache-Control: no-cache
[
{
"prefix": "global",
"name": "label1"
},
{
"prefix": "global",
"name": "label2"
}
]

Adding product via google shopping json API 400 must specify product

I'm having trouble getting a product insertion request working with google shopping API (https://developers.google.com/shopping-content/v2/reference/v2/products/insert). I'm sending an authenticated post request to https://www.googleapis.com/content/v2/shop_id/products?dryRun=true but only getting status: 400 with error message:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "[product] INSERT request must specify product"
}
],
"code": 400,
"message": "[product] INSERT request must specify product"
}
}
My request looks like this (shortened for brevity and ssl encrypted)
POST /content/v2/<removed>/products?dryRun=true HTTP/1.1
Host: www.googleapis.com
Content-Length: 2102
accept-encoding: gzip, deflate
authorization: Bearer <removed>
user-agent: Python-httplib2/0.9.1 (gzip)
{
"offerId": 4572,
"gtin": "4048669296057",
"googleProductCategory": "Apparel & Accessories > Clothing",
"targetCountry": "se",
"title": "Puma Sweat Pants",
"onlineOnly": true,
"price": {
"currency": "SEK",
"value": "1337"
},
"channel": "online",
"contentLanguage": "sv",
"brand": "Puma",
"link": "http://example.com/produkt/puma-sweat-pants"
}
I know the request is correctly authenticated as I can remove the authentication and get a different message.
Googles Common errors page (https://developers.google.com/shopping-content/v2/how-tos/common-errors) suggests that this is a batch job, but that would be the url https://www.googleapis.com/content/v2/products/batch
I found the reason for my troubles: I was not sending the Content-Type: application/json header.

Docusign rest api composite template error

I've made composite templates and had them working before, but I'm suddenly getting an error and have no idea why this is causing an issue. Here's my request:
POST https://demo.docusign.net/restapi/v2/accounts/356019/envelopes HTTP/1.1
Host: demo.docusign.net
X-DocuSign-Authentication: <DocuSignCredentials><Username>test#gmail.com</Username><Password>*****</Password><IntegratorKey>****</IntegratorKey></DocuSignCredentials>
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
Accept: application/json
Content-Length: 807319
Expect: 100-continue
Connection: Keep-Alive
--MY_BOUNDARY
Content-Type: application/json
Content-Disposition: form-data
{
"emailSubject": "Please Docusign this",
"emailBlurb": "This is a test... Also sign this form",
"enableWetSign": "true",
"status": "sent",
"compositeTemplates": [
{
"inlineTemplates": [
{
"sequence": "1",
"recipients": {
"signers": [
{
"email": "test#gmail.com",
"name": "test",
"recipientId": "1"
}
]
}
}],
"document":
{
"documentId": "1",
"name": "test0",
"fileExtension": "pdf"
}
}
]
}
--MY_BOUNDARY
Content-Type: application/pdf
Content-Disposition: file; filename="test0.pdf"; documentid="1"
<pdf bytes here>
--MY_BOUNDARY--
I have this working with server templates, but it seems like anything that requires the document object gives me a bad request. The request I'm getting is:
Request Error: BadRequestDocuSign Error: {
"errorCode": "UNSPECIFIED_ERROR",
"message": "the document is corrupt, rebuilding failed"
}
I've read the pdf bytes in another program and have successfully created a pdf from it, so I'm not sure what could be causing this issue. Does anybody know what the problem may be? Thank you for your time.