I've been trying to follow the docs at MessageBird to test out sending a verification SMS. But when I execute the curl command, the returned response is as expected here:
{"id":"e41c509641a34324a0e1333a4e87d84d","href":"https://rest.messagebird.com/verify/e41c509641a34324a0e1333a4e87d84d","recipient":447000000000,"originator":"+447000000000","type":"sms","reference":null,"messages":{"href":"https://rest.messagebird.com/messages/d18f22ae466g4c349799404d878c9815","id":"d18f22ae466g4c349799404d878c9815"},"status":"sent","createdDatetime":"2021-11-11T15:19:01+00:00","validUntilDatetime":"2021-11-11T15:19:31+00:00"}
But, if you open up the href link from the response it gives the following error:
{"errors":[{"code":20,"description":"message not found","parameter":null}]}
This is the curl request that I use:
curl --location --request POST 'https://rest.messagebird.com/verify' --header 'Authorization: AccessKey ACCESS_KEY' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'recipient=+447000000000' --data-urlencode 'originator=07000000000'
Make sure that you are using a Live key and not the Test key, as the Test environment does not store any of your requests.
If you are looking for a sample response to work with, here is one I just got back:
GET https://rest.messagebird.com/verify/<VID>
{
"id": "<VID>",
"href": "https://rest.messagebird.com/verify/<VID>",
"recipient": 27830000000,
"originator": "Code",
"type": "sms",
"reference": null,
"messages": {
"href": "https://rest.messagebird.com/messages/<MID>",
"id": "<MID>"
},
"status": "sent",
"createdDatetime": "2021-11-11T16:25:06+00:00",
"validUntilDatetime": "2021-11-11T16:25:36+00:00"
}
GET https://rest.messagebird.com/messages/<MID>
{
"id": "<MID>",
"href": "https://rest.messagebird.com/messages/<MID>",
"direction": "mt",
"type": "sms",
"originator": "Code",
"body": "",
"reference": null,
"validity": null,
"gateway": 10,
"typeDetails": {
"verify": true
},
"datacoding": "plain",
"mclass": 1,
"scheduledDatetime": null,
"createdDatetime": "2021-11-11T16:25:07+00:00",
"recipients": {
"totalCount": 1,
"totalSentCount": 1,
"totalDeliveredCount": 1,
"totalDeliveryFailedCount": 0,
"items": [
{
"recipient": 27830000000,
"originator": null,
"status": "delivered",
"statusDatetime": "2021-11-11T16:25:14+00:00",
"recipientCountry": "South Africa",
"recipientCountryPrefix": 27,
"recipientOperator": "",
"messageLength": 20,
"statusReason": "successfully delivered",
"price": {
"amount": 0.021,
"currency": "EUR"
},
"mccmnc": "65507",
"mcc": "655",
"mnc": "07",
"messagePartCount": 1
}
]
}
}
Related
I am fairly new to WP programming and not that skill with backend work.
A client recently asked to add an API to the current form they have on their website. We are using the Contact Form 7 plugin for submissions.
Below is the REST API they sent over to add to the form. I am unsure how to place the code to the form.
Any guidance is greatly appreciated.
Web Service Type: REST
Endpoint: https://api.anasight.com/emive
Method: POST
Encoding: application/json
API KEY must be passed in header named ‘x-api-key’
Concurrency limits: 500 requests / sec
Data Model:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "PersonLite",
"type": "object",
"required": [ "email","ip","regdttm","sourceurl","flex1" ],
"properties": {
"email": {
"type": "string",
"description": "The person's email address."
},
"ip": {
"type": "string",
"description": "The person's IP address captured at registration."
},
"regdttm": {
"type": "string",
"description": "The timestamp when the person registered to receive emails."
},
"sourceurl": {
"type": "string",
"description": "The url of the site that collected the registration."
},
"firstname": {
"type": "string",
"description": "The person's first name."
},
"lastname": {
"type": "string",
"description": "The person's last name."
},
"city": {
"type": "string",
"description": "The person's city."
},
"state": {
"type": "string",
"description": "The person's state."
},
"zip": {
"type": "string",
"description": "The person's ZIP code."
},
"listid": {
"type": "string",
"description": "The listid from the publisher."
},
"flex1": {
"type": "string",
"description": "Please send value of E for emive records and M for Myza records"
}
}
}
Sample CURL request:
curl --silent --show-error -H "Accept: application/json" -H "Content-Type: application/json" -H "x-api-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" --data '{"firstname":"Joe","lastname":"Johnson","email":"joe#example.com","city":"Roswell","state":"NM","zip":"12345-6789","ip":"127.0.0.1","regdttm":"2021-05-11 14:25:00","sourceurl":"sendmegreatoffers.com"}' https://api.anasight.com/emive
I am passing a post request to Insomnia via the REST API to an arbitrary record type.
Title goes well and has the following structure
name: title value : Hello world
But the ACF fields come empty
I add to the request
name: poleacf, and value: Field text
But I only get the name and the fields come empty
This is how the structure looks like:
"id": 242,
"date": "2022-08-24T12:34:44",
"date_gmt": "2022-08-24T09:34:44",
"guid": {
"rendered": "https:\/\/mymerro.xn----gtbemkpb3brp9h.xn--p1ai\/?post_type=reviews&p=242",
"raw": "https:\/\/mymerro.xn----gtbemkpb3brp9h.xn--p1ai\/?post_type=reviews&p=242"
},
"modified": "2022-08-24T12:34:44",
"modified_gmt": "2022-08-24T09:34:44",
"password": "",
"slug": "",
"status": "draft",
"type": "reviews",
"link": "/?post_type=reviews&p=242",
"title": {
"raw": "Привет",
"rendered": "Привет"
},
"featured_media": 0,
"template": "",
"meta": {
"inline_featured_image": false
},
"permalink_template": "https:\/\/mymerro.xn----gtbemkpb3brp9h.xn--p1ai\/reviews\/%pagename%\/",
"generated_slug": "privet",
"acf": {
"opisanie": null,
"nazvanie_sobytiya": null,
"nazvanie_kompanii": null,
"otzyv_aktiven": null,
"oczenka": null,
"autor": null
},
Please help me correctly register the QUERY values in Insomnia so that the fields with ACF also do not come empty
I am trying to send a request from my front-end to my back-end comprised of Java Servlets but for some reason GCP receives the request as an OPTIONS type instead of a PUT or DELETE and then none of the functionality or logging works, GET and POST work fine.
{
"protoPayload": {
"#type": "type.googleapis.com/google.appengine.logging.v1.RequestLog",
"appId": "g~servletcoursework-336513",
"versionId": "20211231t193717",
"requestId": "61cf5ebf00ff0c34825de6b9a60001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"ip": "84.70.147.60",
"startTime": "2021-12-31T19:49:19.801880Z",
"endTime": "2021-12-31T19:49:19.814140Z",
"latency": "0.012260s",
"method": "OPTIONS",
"resource": "/deleteFilm?format=xml&id=10001",
"httpVersion": "HTTP/1.1",
"status": 200,
"responseSize": "68",
"referrer": "https://d2icepsfo58cxr.cloudfront.net/",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36",
"urlMapEntry": "unused",
"host": "servletcoursework-336513.nw.r.appspot.com",
"cost": 7.598999999999999e-9,
"instanceIndex": -1,
"finished": true,
"instanceId": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b",
"appEngineRelease": "1.9.71",
"traceId": "0184c35a91f8e703c73e9f79e6a522e6",
"first": true,
"traceSampled": true
},
"insertId": "61cf5ebf000c6cc558e7834c",
"httpRequest": {
"status": 200
},
"resource": {
"type": "gae_app",
"labels": {
"zone": "europe-west2-2",
"project_id": "servletcoursework-336513",
"version_id": "20211231t193717",
"module_id": "default"
}
},
"timestamp": "2021-12-31T19:49:19.801880Z",
"labels": {
"clone_id": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b"
},
"logName": "projects/servletcoursework-336513/logs/appengine.googleapis.com%2Frequest_log",
"operation": {
"id": "61cf5ebf00ff0c34825de6b9a60001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"producer": "appengine.googleapis.com/request_id",
"first": true,
"last": true
},
"trace": "projects/servletcoursework-336513/traces/0184c35a91f8e703c73e9f79e6a522e6",
"receiveTimestamp": "2021-12-31T19:49:19.816277372Z",
"traceSampled": true
}
Yet if I do the same request via Postman it works completely fine:
{
"protoPayload": {
"#type": "type.googleapis.com/google.appengine.logging.v1.RequestLog",
"appId": "g~servletcoursework-336513",
"versionId": "20211231t193717",
"requestId": "61cf5f9300ff023d16e28dbc540001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"ip": "54.86.50.139",
"startTime": "2021-12-31T19:52:51.186694Z",
"endTime": "2021-12-31T19:52:51.227747Z",
"latency": "0.041053s",
"megaCycles": "4000",
"method": "DELETE",
"resource": "/deleteFilm?format=xml&id=10001",
"httpVersion": "HTTP/1.1",
"status": 200,
"responseSize": "195",
"userAgent": "PostmanRuntime/7.28.4",
"urlMapEntry": "unused",
"host": "servletcoursework-336513.nw.r.appspot.com",
"cost": 2.1792e-8,
"instanceIndex": -1,
"finished": true,
"instanceId": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b",
"appEngineRelease": "1.9.71",
"traceId": "4700825c5878ed9191d27216bd8b752a",
"first": true,
"traceSampled": true
},
"insertId": "61cf5f9300037a2457bd3063",
"httpRequest": {
"status": 200
},
"resource": {
"type": "gae_app",
"labels": {
"version_id": "20211231t193717",
"zone": "europe-west2-2",
"project_id": "servletcoursework-336513",
"module_id": "default"
}
},
"timestamp": "2021-12-31T19:52:51.186694Z",
"labels": {
"clone_id": "00c61b117c8704a9c5c71617a78aab0d6d5dd3630b836d3885a5565c92e147a58efbc9180d22c59db107f4946306db18bbe33383d93470f26dada4e4acbd199e9d276494d392ba7d0b"
},
"logName": "projects/servletcoursework-336513/logs/appengine.googleapis.com%2Frequest_log",
"operation": {
"id": "61cf5f9300ff023d16e28dbc540001677e736572766c6574636f75727365776f726b2d3333363531330001323032313132333174313933373137000100",
"producer": "appengine.googleapis.com/request_id",
"first": true,
"last": true
},
"trace": "projects/servletcoursework-336513/traces/4700825c5878ed9191d27216bd8b752a",
"receiveTimestamp": "2021-12-31T19:52:51.232339381Z",
"traceSampled": true
}
I have no idea why my HTTP request isn't working when it comes from my front-end, it was working fine when I tested locally. I have logging of different variables in order to debug my backend and it logs if I use postman but not if I send the request from my front-end.
It’s almost as if the (I assume) pre-flight requests breaks the behaviour of the Servlet I’m hitting, and I’m not sure how to fix this
I have JSON data about R request that i need to write with necessary url, access token, parameters and other things, which must be included in httr query. I got it from getpostman item. Here it is:
{
"name": "GET /tablesbyquery",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "hnjP4YUF-woR0jhUyJIByeOI_q8jF99jK5WlQ", #fake for example
"type": "string"
}
]
},
"method": "GET",
"header": [],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://somesource.os-pub.com/tables/tablesbyquery?timePeriod=actual&sort=utdDate,asc&query=&isNotEmptyStatus=false&size=20&page=0&providerId=",
"protocol": "http",
"host": [
"somesource",
"os-pub",
"com"
],
"path": [
"tables",
"tablesbyquery"
],
"query": [
{
"key": "timePeriod",
"value": "actual"
},
{
"key": "sort",
"value": "utdDate,asc"
},
{
"key": "query",
"value": ""
},
{
"key": "isNotEmptyStatus",
"value": "false"
},
{
"key": "size",
"value": "20"
},
{
"key": "page",
"value": "0"
},
{
"key": "providerId",
"value": ""
}
]
}
},
"response": []
}
I need to write R request query to GET necessary data. How it should look like? Im new in url and i have written this part:
url <- "http://somesource.os-pub.com/tables/tablesbyquery?timePeriod=actual&sort=utdDate,asc&query=&isNotEmptyStatus=false&size=20&page=0&providerId="
access_token <- "hnjP4YUF-woR0jhUyJIByeOI_q8jF99jK5WlQ"
res <- GET(url, access_token)
content(res, "parsed")
But it doesn't work.
I have this code for searching with frog AQL api:
items.find({"name":{"$match":"abab-2.0.3.json"}})
its come back as response
{
"results": [
{
"repo": "npm-remote-cache",
"path": ".npm/abab",
"name": "abab-2.0.3.json",
"type": "file",
"size": 1124,
"created": "2020-05-07T21:58:12.633Z",
"created_by": "_system_",
"modified": "2020-05-07T21:58:12.604Z",
"modified_by": "_system_",
"updated": "2020-05-07T21:58:12.633Z"
}
],
"range": {
"start_pos": 0,
"end_pos": 1,
"total": 1
}
}
But I need only the "total" field.
There is a way to get only that field?
You can achieve this with jq:
cat response | jq .range.total