[GH-ISSUE #463] Message Results API always returns an empty message_result array #327

Open
opened 2026-02-28 01:24:09 +03:00 by kerem · 7 comments
Owner

Originally created by @MrAutoIt on GitHub (Jan 8, 2017).
Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/463

Expected behavior

When the Message Results API doses a post task results it should post the message_result array like in the example the documentation.
POST http://localhost/sms/index.php?task=result

{
    "message_result": [
        {
            "uuid": "052bf515-ef6b-f424-c4ee",
            "sent_result_code": 0,
            "sent_result_message": "SMSSync Message Sent"
            "delivered_result_code": -1,
            "delivered_result_message": ""
        }
}

Actual behavior

The message_results array always comes back empty.

{
    "message_result": []
}

Steps to reproduce the behavior

Per the documentation we are sending "message_uuids" through the GET task=result. It response to the API with something like this:

{
  "message_uuids": [
     "3a9ec5f2-6fa4-4f8b-b063-2d7e5267dd08"
  ]
}

However, the POST task=results always sends back an empty array. Like this:

{
    "message_result": []
}

Any help would be greatly appreciated. We have tried everything we can think of and are out of ideas on why the delivery report does not seem be working.

Originally created by @MrAutoIt on GitHub (Jan 8, 2017). Original GitHub issue: https://github.com/ushahidi/SMSSync/issues/463 ### Expected behavior When the Message Results API doses a post task results it should post the message_result array like in the example the documentation. POST http://localhost/sms/index.php?task=result ``` { "message_result": [ { "uuid": "052bf515-ef6b-f424-c4ee", "sent_result_code": 0, "sent_result_message": "SMSSync Message Sent" "delivered_result_code": -1, "delivered_result_message": "" } } ``` ### Actual behavior The message_results array always comes back empty. ``` { "message_result": [] } ``` ### Steps to reproduce the behavior Per the documentation we are sending "message_uuids" through the GET task=result. It response to the API with something like this: ``` { "message_uuids": [ "3a9ec5f2-6fa4-4f8b-b063-2d7e5267dd08" ] } ``` However, the POST task=results always sends back an empty array. Like this: ``` { "message_result": [] } ``` Any help would be greatly appreciated. We have tried everything we can think of and are out of ideas on why the delivery report does not seem be working.
Author
Owner

@rjmackay commented on GitHub (Jan 25, 2017):

Its not clear. Is this the wrong data sent to your API by SMSSync? or the wrong data return by the API (Ushahidi v2 or v3) ?

<!-- gh-comment-id:275003884 --> @rjmackay commented on GitHub (Jan 25, 2017): Its not clear. Is this the wrong data sent to your API by SMSSync? or the wrong data return by the API (Ushahidi v2 or v3) ?
Author
Owner

@MrAutoIt commented on GitHub (Jan 25, 2017):

SMSSync v3.0.5

The wrong data is sent back by SMSSync. Or to be more clear just an empty array.

<!-- gh-comment-id:275005181 --> @MrAutoIt commented on GitHub (Jan 25, 2017): SMSSync v3.0.5 The wrong data is sent back by SMSSync. Or to be more clear just an empty array.
Author
Owner

@damien-roche commented on GitHub (Jan 27, 2017):

@rjmackay I have recently created a simple service to test this and run into exactly the same problem.

Everything works up until delivery reports - creating messages, queuing, sending..

But despite the android app receiving the correct message uuids from the GET /sync?task=result endpoint (from logs triggered by android app):

Started GET "/api/sync?task=result" for 68.104.79.58 at 2017-01-27 22:10:44 +0000
Completed 200 OK in 9ms

..triggered by console..

curl --header "Content-Type: application/json" https://myserver.com/api/sync?task=result
{"message_uuids":["9f2ca396-17a3-495d-b339-ea8aa4e812d6","38dfd4ba-7475-4be9-b192-48f8079dd3b9"]}

.. it proceeds to POST an empty message_result to /sync?task=result..

Started POST "/api/sync?task=result" for 68.104.79.58 at 2017-01-27 22:10:45 +0000
Processing by Api::MessagesController#post as JSON
Parameters: {"message_result"=>"[]", "task"=>"result", "message"=>{}}

Application settings:

Settings >> General >> SMS Delivery Report (enabled)
Settings >> Task >> Enable Task Checking (enabled)
Settings >> Task >> Set A Specific Time Frequency (1 minute)
Settings >> Task >> Enable Message Results API (enabled)

<!-- gh-comment-id:275789751 --> @damien-roche commented on GitHub (Jan 27, 2017): @rjmackay I have recently created a simple service to test this and run into exactly the same problem. Everything works up until delivery reports - creating messages, queuing, sending.. But despite the android app receiving the correct message uuids from the GET /sync?task=result endpoint (from logs triggered by android app): > Started GET "/api/sync?task=result" for 68.104.79.58 at 2017-01-27 22:10:44 +0000 > Completed 200 OK in 9ms ..triggered by console.. > curl --header "Content-Type: application/json" https://myserver.com/api/sync?task=result > {"message_uuids":["9f2ca396-17a3-495d-b339-ea8aa4e812d6","38dfd4ba-7475-4be9-b192-48f8079dd3b9"]} .. it proceeds to POST an empty `message_result` to /sync?task=result.. > Started POST "/api/sync?task=result" for 68.104.79.58 at 2017-01-27 22:10:45 +0000 > Processing by Api::MessagesController#post as JSON > Parameters: {"message_result"=>"[]", "task"=>"result", "message"=>{}} Application settings: Settings >> General >> SMS Delivery Report (enabled) Settings >> Task >> Enable Task Checking (enabled) Settings >> Task >> Set A Specific Time Frequency (1 minute) Settings >> Task >> Enable Message Results API (enabled)
Author
Owner

@aoduor commented on GitHub (Jan 29, 2017):

@dalezak @brandonrosage flagging this as well for you to look into

<!-- gh-comment-id:275893702 --> @aoduor commented on GitHub (Jan 29, 2017): @dalezak @brandonrosage flagging this as well for you to look into
Author
Owner

@khilje125 commented on GitHub (Apr 30, 2017):

SMSSync Version 3.1.1
I have an API all is working fine. Even Delivery reports activated on Network provider. But SMSSync always respond back an empty Json Array while getting Delivery response.
For Example i send following In Get Request From API to SMSSync
URL : http://mydomain.com/api/SMSAPI/SMSSyncGateway?task=result
Response Data From API to SMSSync :

{
"message_uuids": [
"8e4f72d3-1184-41f6-97cf",
"5c4d1cc5-1397-425f-ae86",
"9129fab1-bf1e-43ba-94b9",
"71464086-4b4b-4b3f-8790",
"3d5ca303-345a-435c-8ac7",
"7dd6acd4-13fc-48c9-84e4",
"3b8b531d-2b7d-47e8-9e48",
"980b62a1-009c-4db6-b44d",
"cbfdb6e3-f99c-4a25-aed0",
"b50c402c-a03f-4ebd-a533",
"f4820768-53af-4a2d-9a96",
"f0af1679-9eab-4e77-9732"
]
}

Suppose these UUID's awaiting for Delivery report.

But in Post Request From SMSSync to API

Delivery Result :{
"message_result": "[]"
}

Please respond me back where i doing wrong in setting. In SMSSync SMS Develiery repost is Checked.
If any one have some solution is would be greatly Thanks full.

<!-- gh-comment-id:298260373 --> @khilje125 commented on GitHub (Apr 30, 2017): SMSSync Version 3.1.1 I have an API all is working fine. Even Delivery reports activated on Network provider. But SMSSync always respond back an empty Json Array while getting Delivery response. For Example i send following In Get Request From API to SMSSync URL : http://mydomain.com/api/SMSAPI/SMSSyncGateway?task=result Response Data From API to SMSSync : ``` { "message_uuids": [ "8e4f72d3-1184-41f6-97cf", "5c4d1cc5-1397-425f-ae86", "9129fab1-bf1e-43ba-94b9", "71464086-4b4b-4b3f-8790", "3d5ca303-345a-435c-8ac7", "7dd6acd4-13fc-48c9-84e4", "3b8b531d-2b7d-47e8-9e48", "980b62a1-009c-4db6-b44d", "cbfdb6e3-f99c-4a25-aed0", "b50c402c-a03f-4ebd-a533", "f4820768-53af-4a2d-9a96", "f0af1679-9eab-4e77-9732" ] } ``` Suppose these UUID's awaiting for Delivery report. But in Post Request From SMSSync to API ``` Delivery Result :{ "message_result": "[]" } ``` Please respond me back where i doing wrong in setting. In SMSSync SMS Develiery repost is Checked. If any one have some solution is would be greatly Thanks full.
Author
Owner

@MajorChump commented on GitHub (Nov 2, 2017):

Easy one to fix. Issue is its only sending pending messages back to the API (which by this step there shouldnt be any) and failed messages because its using mMessageDataSource.fetchPendingByUuid(uuid).

https://github.com/ushahidi/SMSSync/blob/master/smssync/src/main/java/org/addhen/smssync/data/message/ProcessMessageResult.java#L97

Code should be something a long the lines of:

Message message = mMessageDataSource.fetchByUuid(uuid);
if (message.status != Message.Status.UNCONFIRMED.name()) {

I'll open a PR if it'll get merged. This is untested at the moment will fork, compile and test unless you guys (@eyedol) can do in the next couple of hours?

<!-- gh-comment-id:341469863 --> @MajorChump commented on GitHub (Nov 2, 2017): Easy one to fix. Issue is its only sending pending messages back to the API (which by this step there shouldnt be any) and failed messages because its using `mMessageDataSource.fetchPendingByUuid(uuid)`. https://github.com/ushahidi/SMSSync/blob/master/smssync/src/main/java/org/addhen/smssync/data/message/ProcessMessageResult.java#L97 Code should be something a long the lines of: `Message message = mMessageDataSource.fetchByUuid(uuid);` `if (message.status != Message.Status.UNCONFIRMED.name()) {` I'll open a PR if it'll get merged. This is untested at the moment will fork, compile and test unless you guys (@eyedol) can do in the next couple of hours?
Author
Owner

@MajorChump commented on GitHub (Nov 2, 2017):

PR above fixes the issue, tested with my production app and everything has cleaned up and marked delivered.

<!-- gh-comment-id:341566610 --> @MajorChump commented on GitHub (Nov 2, 2017): PR above fixes the issue, tested with my production app and everything has cleaned up and marked delivered.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SMSSync#327
No description provided.