API methods inconsistent
Closed this issue · 7 comments
The new notify
methods are called like GET /notify/:id
while others require GET /messages?id=:id
.
- Are the other methods also transformed to
/method/:id
? - Can you tell me when that's about to happen?
- The docs use
/messages/:id
but they don't work.
Do you mean verify
instead of notify
?
The default for our API is /:endpoint/:id
, there should not be any endpoint that works with a ?
. Do you have some example requests that don't work as expected?
Yes verify
indeed, my apologies.
The requests below fail with /:endpoint/:id
// API-logs /logs/view/api/703691675
GET /messages/b9e9e310455df500dd2d256b90987680
{ [Error: api error]
statusCode: 404,
errors: [ { code: 20, description: 'message not found', parameter: null } ] }
// API-logs /logs/view/api/703691695
GET /voicemessages/4510f2d0455df500e191347a99121160
{ [Error: api error]
statusCode: 404,
errors: [ { code: 20, description: 'message not found', parameter: null } ] }
// API-logs /logs/view/api/703691705
GET /hlr/21d2d830455df500e4fbba1h77174011
{ [Error: api error]
statusCode: 404,
errors: [ { code: 20, description: 'hlr not found', parameter: null } ] }
The 404 error is a valid response from the API. So, yes, it failed to get the messages, but the endpoint works.
You get these responses after first creating a new message? If so, can you show the whole request cycle: create a message, view a message?
Do note that if you use the TEST api key, objects will not be really created - so a view on a just create
object with a test key will always throw a 404.
Okay, I see the difference now.
/:endpoint/:id
returns theerrors
array withmessage not found
/:endpoint?id=:id
returns a standard object withtotalCount: 0
anditems: []
I still find this behavior inconsistent, but I'll update the code to use the correct endpoints.
Full request/response:
messages.create
Request
POST https://rest.messagebird.com/messages
Accept: */*
Content-Type: text/plain
Authorization: AccessKey test_key
Accept-Language: nl-nl
Accept-Encoding: gzip, deflate
{ originator: 'node-js',
recipients: '31610948431',
type: 'sms',
body: 'Test message from node v0.12.7',
gateway: 2 }
Response
Access-Control-Allow-Origin: *
Keep-Alive: timeout=2, max=100
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
X-Powered-By: PHP/5.6.11-1~dotdeb+7.1
Server: Apache
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Expires: 0
Access-Control-Allow-Headers: Authorization
Cache-Control: must-revalidate, post-check=0, pre-check=0
Date: Sat, 29 Aug 2015 10:49:20 GMT
Access-Control-Allow-Credentials: true
Content-Length: 578
Connection: Keep-Alive
X-UA-Compatible: IE=edge,chrome=1
Vary: Authorization
{ id: '6432e450355e18e3076dc91b20946080',
href: 'https://rest.messagebird.com/messages/6432e450355e18e3076dc91b20946080',
direction: 'mt',
type: 'sms',
originator: 'node-js',
body: 'Test message from node v0.12.7',
reference: null,
validity: null,
gateway: 2,
typeDetails: {},
datacoding: 'plain',
mclass: 1,
scheduledDatetime: null,
createdDatetime: '2015-08-29T10:49:20+00:00',
recipients:
{ totalCount: 1,
totalSentCount: 1,
totalDeliveredCount: 0,
totalDeliveryFailedCount: 0,
items:
[ { recipient: 31610948431,
status: 'sent',
statusDatetime: '2015-08-29T10:49:20+00:00' } ]
}
}
messages.read /:endpoint/:id
Request
GET https://rest.messagebird.com/messages/6432e450355e18e3076dc91b20946080
Accept-Language: nl-nl
Accept: */*
Authorization: AccessKey test_key
Accept-Encoding: gzip, deflate
Response
Access-Control-Allow-Origin: *
Keep-Alive: timeout=2, max=100
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
X-Powered-By: PHP/5.6.11-1~dotdeb+7.1
Server: Apache
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Expires: 0
Access-Control-Allow-Headers: Authorization
Cache-Control: must-revalidate, post-check=0, pre-check=0
Date: Sat, 29 Aug 2015 10:51:27 GMT
Access-Control-Allow-Credentials: true
Content-Length: 75
Connection: Keep-Alive
X-UA-Compatible: IE=edge,chrome=1
Vary: Authorization
{ errors:
[ { code: 20,
description: 'message not found',
parameter: null
} ]
}
messages.read /:endpoint?id=:id
Request
GET https://rest.messagebird.com/messages?id=6432e450355e18e3076dc91b20946080
Accept-Language: nl-nl
Accept: */*
Authorization: AccessKey test_key
Accept-Encoding: gzip, deflate
Response
Access-Control-Allow-Origin: *
Keep-Alive: timeout=2, max=100
Pragma: no-cache
Content-Type: application/json; charset=UTF-8
X-Powered-By: PHP/5.6.11-1~dotdeb+7.1
Server: Apache
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Expires: 0
Access-Control-Allow-Headers: Authorization
Cache-Control: must-revalidate, post-check=0, pre-check=0
Date: Sat, 29 Aug 2015 10:50:35 GMT
Access-Control-Allow-Credentials: true
Content-Length: 122
Connection: Keep-Alive
X-UA-Compatible: IE=edge,chrome=1
Vary: Authorization
{ offset: 0,
limit: 20,
count: 0,
totalCount: 0,
links: {
first: null,
previous: null,
next: null,
last: null
},
items: []
}
The endpoint /:endpoint?id=:id
sends back a list of objects. This is an undocumented feature of our API and should, as such, not be included in the library (for now).
Alright, issue resolved