There is no recipient info in response

  • 1
  • Problem
  • Updated 5 months ago
Hi,

I've tried to get fax  recipient info, but I always get null in response.


Photo of zgrada zgrada

zgrada zgrada

  • 230 Points 100 badge 2x thumb

Posted 5 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,396 Points 5k badge 2x thumb
Can you post some code where you send the fax message and check the recipient info instead of that screen shot. That way I can help you better.

+ Phong
Photo of zgrada zgrada

zgrada zgrada

  • 230 Points 100 badge 2x thumb
Hi,

I do not send a fax, but I've tried to download fax attachments. Here is code:

await rc.Authorize(Username, Extension, Password);
rc.AutoRefreshToken = false;

var account = rc.Restapi().Account();
var extension = account.Extension();
var response = await extension.MessageStore().List(new { direction = "Inbound", messageType = "Fax", messageStatus = "Received" });

if(response != null && response.records.Length > 0)
{
    // fax
    var messages = response.records.Where(m => m.messageStatus != "SendingFailed");

    foreach (var m in messages)
    {
        foreach (var a in m.attachments)
        {
            var messageResponse = await extension.MessageStore(m.id).Content(a.id).Get();

            if (messageResponse.data != null && messageResponse.data.Length > 0)
            {
                var content = messageResponse.data;
                
                    model.FileName = a.id,
                    model.FileContent = content,
                    model.To=m.to.Select(x=>x.phoneNumber).FirstOrDefault()
            }
        }
    }
(Edited)
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,396 Points 5k badge 2x thumb
Just a quick note, there is no messageStatus query parameter so you get request params is invalid. Not 100% sure if that is the only cause of the problem but you should remove it and run the code again. Also, if you dont specify the dateFrom and dateTo params, it will just read the message store for the last 24 hrs, which may not have the fax you are looking for.

So try something like this:

var response = await extension.MessageStore().List(new { direction = "Inbound", messageType = "Fax", dateFrom = "2018-10-12T00:00:00.000Z", dateTo = "2018-12-12T00:00:00.000Z" });

Hope this helps!
+ Phong
Photo of zgrada zgrada

zgrada zgrada

  • 230 Points 100 badge 2x thumb
Here is the result. The same thing. NULL value for "to" property.
(Edited)
Photo of Phong Vu

Phong Vu, Devangelist

  • 5,396 Points 5k badge 2x thumb
Sorry that I misunderstood your question as you said you got the recipient as null in the response. I thought that the response was null.

Anyway, the message list (message-store) API reference is generic and it did not mention about the "to" field for inbound Fax message. For a fax record item with inbound type, the "to" field won't exist. Instead, the recipient's phone number is in the subject field. I see you wipe it out in your screenshot above. So have a look at that number and use it as the recipient's number.

+ Phong
Photo of zgrada zgrada

zgrada zgrada

  • 230 Points 100 badge 2x thumb
Ok, thanks. It should work.