Error 38783 on switchvox.users.fax.getFile

Talk with others about developing applications for Switchvox

Moderators: bmdhacks, dpodolsky, tristand, jwitt, joshuas

Error 38783 on switchvox.users.fax.getFile

Postby bdill » Mon Aug 24, 2009 9:29 am

I’m testing with the Switchvox Extend API Test Suite

I'm using an administrative account with maxed out permissions on the SwitchVox

I’ve had success with some methods (ex: "switchvox.extensions.getInfo"), but not with switchvox.users.fax.getFile".

I always get the following response:
Code: Select all
<error code="38783" message="Invalid access level to run method." />


Note: Since the preview parameter isn’t documented online, I have tried several variants for the "preview" parameter: 0, false, False, empty, excluded (unchecked)…
All got the same error response.

I’m a bit stumped at this point. Can anyone provide any pointers?

FYI, my goal is to move all incoming faxes to another server - preferrably as each one comes it. If that's not possible, I will query SwitchVox every 5 minutes or so and loop through all files in a specific user's folder.
bdill
Newsterisk
 
Posts: 3
Joined: Mon Aug 24, 2009 9:10 am
Location: Nashville, TN

Postby dpodolsky » Mon Aug 24, 2009 11:48 am

This all comes down which account you are using to make the API call.

1. If you are using the main admin account then this call will work fine. The main admin can access any API call on the system.

2. If you are using the user's credentials this call will work as well. So for the username / password use the extension number of the fax mailbox you are trying to check along with their voicemail password. Example: Username: 101, password: 294845

3. If you are using a sub admin account, then you can't access user settings directly. You need to use the API to get the user's credentials and then query as that use (see #2 above). So if you are using the tool suite just enter the user's credentials.


The preview parameter can be 1 or 0 (defaults to 0). If preview is set, it will send you back a gif preview of the first page of the fax (like what shows up in the email). Without preview it sends the entire fax in pdf.

FYI, my goal is to move all incoming faxes to another server


You can certainly use the API to do this to get the fax files and put them on a different server. Another approach would be to change the email address used for incoming faxes. Then when a fax comes in, it immediately be emailed to the mail server and you can locally process the fax attachment there and save it where ever you want.

Hope this helps.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Postby bdill » Mon Sep 14, 2009 10:16 am

Ok. I have THE admin account. I'm getting past the "Invalid access level" error, but I'm still hitting roadblocks.
Note: 1016 is my extension.

Using the test suite, I post:
Code: Select all
<request method="switchvox.users.fax.getFile">
    <parameters>
        <account_id>1016</account_id>
        <message_id>1</message_id>
        <folder>Fax</folder>
    </parameters>
</request>

... and it returns ...
Code: Select all
<response method="switchvox.users.fax.getFile">
   <result>
      <download link="4 NO Mailbox doesn't exist: Fax" />
   </result>
</response>

Now according to this screenshot, it does exist - at the same level as the "INBOX" folder:

Just for grins I tried folder "INBOX" and got
<error code="64128" message="Invalid message ID (1)" />
Well, at least it didn't say that the mailbox doesn't exist. :)

This leads me to 2 questions:
1) Why does it say "Fax" doesn't exist? If the fax isn't in the "Fax" folder, where is it?

2) How does one determine the message ID of a particular fax or voicemail?
bdill
Newsterisk
 
Posts: 3
Joined: Mon Aug 24, 2009 9:10 am
Location: Nashville, TN

Postby utpbx » Mon Sep 14, 2009 2:58 pm

The "account_id" is not the same as your extension number. You need to look up the account_id for extension 1016 and use that instead of "1016"

For example. On the switchvox demo system, I just used the tool suite to find the account_id for extension "101" The account_id for extension "101" is actually "5714" The "5714" is what I would need to use in your example.
utpbx
Oldsterisk
 
Posts: 172
Joined: Tue May 26, 2009 11:22 am

Postby dpodolsky » Tue Sep 15, 2009 9:57 am

bdill,
You are getting close, but you are missing some API calls that you need to make first in order to get the correct ids for both accounts and messages. Here are some steps that should help you out.


Step 1 : get the account id for an extension
Just like utpbx said in the previous post you need to get extension 1016's account id. You can do this with an API call using the tool suite. User Info -> switchvox.users.getMyInfo. This will spit out the full extension info along with the account id.

Step 2 : Get the correct message id.
Next you need to get the message id for your fax. This is where you will call "switchvox.users.voicemail.getList" and pass in the Fax folder.

Code: Select all
<request method="switchvox.users.voicemail.getList">
    <parameters>
        <account_id>1107</account_id>
        <folder>Fax</folder>
    </parameters>
</request>


This then spits out all the messages with ids that are in the fax folder. Find the one you want to get the fax file for and then call your switchvox.users.fax.getFile.

Sample output:
Code: Select all
<response method="switchvox.users.voicemail.getList">
   <result>
      <messages folder="Fax" page_number="1" total_pages="1" items_per_page="50" total_items="2">
         <message id="1" original_mailbox="302" caller_id="David &lt;5551212&gt;" date="2008-11-21 8:51:25" duration="0.00" read="Yes" />
         <message id="2" original_mailbox="302" caller_id="SWITCHVOX &lt;8584578299&gt;" date="2009-03-27 17:11:38" duration="0.00" read="Yes" />
      </messages>
   </result>
</response>


Hope this helps.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Postby bdill » Tue Sep 15, 2009 3:57 pm

utpbx and dpodolsky,
THANKS! That got it.

One last minor thing. I don't suppose that there's a "switchvox.users.fax.getFiles" method coming down the pipe anytime soon?

Similar syntax as .getFile except that you could specify multiple IDs like in "switchvox.users.voicemail.remove".

... and for the icing on the cake - an "all" mechanism to request download links to all files in the specified folder.

Don't you love ungrateful users who always want more, more more? :D
bdill
Newsterisk
 
Posts: 3
Joined: Mon Aug 24, 2009 9:10 am
Location: Nashville, TN

Postby dpodolsky » Tue Sep 15, 2009 4:39 pm

There isn't a getFiles request, but you can simulate this behavior using a batch request. With a batch request you can make multiple requests (getFile,getFile,getFile) all in one batch request. See my Blog post about this for more information, but it might be what you are looking for:

http://developers.digium.com/switchvox/blog/?p=365
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Re: Error 38783 on switchvox.users.fax.getFile

Postby alisade » Mon Aug 06, 2012 12:24 pm

I have a sub admin,
which API call do I use to get user password to retrieve the voicemail files per your instructions above?
alisade
Newsterisk
 
Posts: 1
Joined: Wed Jul 18, 2012 10:40 am

Re: Error 38783 on switchvox.users.fax.getFile

Postby dpodolsky » Mon Aug 06, 2012 6:09 pm

There isn't an API to get any user's password for security reasons. Sub admins don't have the same permissions to access the user API as the super admin. You need to either access the user API as the super admin, or have the password for the user and access the API as that user.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm


Return to Switchvox Developers

Who is online

Users browsing this forum: No registered users and 2 guests