Discussions

Expand all | Collapse all

How to I properly get a webhook to fire for AddRecord?

Stephen Stephen12-15-2016 13:36

Johnny QuickBase12-16-2016 19:34

  • 1.  How to I properly get a webhook to fire for AddRecord?

    Posted 11-08-2016 04:33

    I am just trying to figure out basic Webhooks. I want to trigger a webhook when a data record changes in Table 1 to add a record to Table #2. I set everything up with 1. When criteria are all set

    2. Endpoint URL goes to the Table #2

    3. XML, QuickBase-Action, API_AddRecord

    4. I think the Message Body is where I'm goofing up, but I find the "help" too advanced. Any good reading suggests with examples to help me get going?

    Field 9 is the one to be updated in Table #2, and [Inventory Total] is the record in Table 1 that changed to cause the webhook to fire.

    <qdbapi>

    <apptoken>--app token here---</apptoken>

    <field fid="9">[Inventory Total]</field>

    </qdbapi>



  • 2.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-08-2016 13:23
    Try add a line like this 

     <usertoken>bxv4tx_bjix_8xxxxxxxx</usertoken> 


    The Webhook actually runs under a userid and takes on that userid's permisisons.  So decide what userid it will run under, and then sign on as that user and go to "My Preferences under the user's name at the top right and then

    Manage User Tokens


    That will give you a long code, similar to the App Token, but in this case it essentially logs in under that userid to execute the Webhook.

    A consideration is to choose a userid which will perhaps out survive your personal access to the app.  For example if you are an App Admin for a Company and you set up a bunch of obscure webhooks under you own userid and then choose not to be immortal, or at least choose not to be an employee for te next 100 years, then its a better idea to set up a Userid which will be owned by the IT department, and last longer than perhaps your personal access to the app.  

    Once that userid assciated with the Usertoken l no longer has access to the app, then it will fail.


  • 3.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-08-2016 13:36
    Mark, Thank you. the usertoken worked perfectly!!!


  • 4.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-08-2016 13:38
    Can you point me to any more good resources for learning how to more robustly write the "message body" portion of webhooks? I'm a quick learner but the help is pretty thin. I prefer more examples to emulate...Thanks!!!!!


  • 5.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-08-2016 13:54
    The help is pretty thin, I agree.  The best examples are in the API help under a particular API call where they give examples.

    here is the API guide

    http://help.quickbase.com/user-assistance/Default.html#apicalls.html

    here, for example is the example for API_AddRecord

    <qdbapi>
       <udata>mydata</udata>
       <ticket>auth_ticket</ticket>
       <apptoken>app_token</apptoken>
       <field name="event_name">party at Lindisfarne</field>
       <field name="description">dress in style of the epoch</field>
       <field name="location">lindisfarne island</field>
       <field name="start_time">06-08-0793</field>
       <field name="end_time">10-14-1066</field>
    </qdbapi>

    Example Using Field IDs

    <qdbapi>
    <udata>mydata</udata>
    <ticket>auth_ticket</ticket>
    <apptoken>app_token</apptoken>
    <field fid="8";>party at Lindisfarne</field>
    <field fid="9">dress in style of the epoch</field>
    <field fid="10">lindisfarne island</field>
    <field fid="11">06-08-0793</field>
    <field fid="12">10-14-1066</field>
    </qdbapi>


    So best I can figure you do not need that <udata> line
    You do not need <ticket>
    but you do need the <usertoken> which is not documented there.


  • 6.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-09-2016 06:39
    Thanks. Here's another question: I had a table with 6 new records added (via connected CSV), but the webhook only fired on 1 of the records? Shouldn't it have recreated 6 new records ?


  • 7.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 11-09-2016 12:54
    I know that Webhooks are "gated" to not run more than 10 per second on any single table.  But I can't explain why 6 did not fire.  You will need to put in a support ticket on that one.


  • 8.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-13-2016 16:39
    API_AddRecord is for single record changes. API_ImportFromCSV is what's needed for your multiple record changes however. Here's what I built to accomplish that previously:

    <qdbapi>

    <usertoken>USERTOKENREMOVED</usertoken>

    <records_csv>

    <![CDATA[

    %repeatOn%

    [old.FieldName1.csv],[old.FieldName2.csv],[old.FieldName3.csv],[old.FieldName4.csv],[old.FieldName5.csv]

    %repeatOff%

    ]]></records_csv>

    <clist>22.16.18.88.12</clist>

    </qdbapi>


  • 9.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-14-2016 22:50
    This issue is that with multi-record edits, only one webhook would fire.  You would need to add 6 records under one webhook fire to capture the 6 changes.

    Similar to how multi-record notifications work, try wrapping your data in %repeatOn% so that if multiple records are added at the same time, all records will be added.  Also, switch your api to API_ImportFromCSV so you can add multiple records.


  • 10.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-15-2016 13:36
    Thanks!


  • 11.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 18:31
    Hate to ask this and sound like a dummy.  What is <udata> and what is <ticket>??


  • 12.  RE: How to I properly get a webhook to fire for AddRecord?



  • 13.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 18:36
    The API guide talks about both of them. I wish there were a better more basic resource to explain this stuff, but I do a lot of copying what works.....


  • 14.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 18:40
    Nope, that's a great question. The udata is a piece of information you can pass along with an API call, and the response you receive back will contain that same information. Its use can be to track internal transactions, response times, etc.

    The ticket is explained in the API_Authenticate documentation here: https://help.quickbase.com/api-guide/index.html#authenticate.html. In general, because API calls are performed from somewhere outside of your database, your application needs to know it's a valid call. Think of your application being locked, and using the API_Authenticate action will generate an access code that's valid for a certain timeframe. Subsequent API calls to your application will include that ticket to be successful.


  • 15.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 18:43
    Ah Ok.   I'm actually trying out my first webhook of creating a record in one table when another record is created.  Trying to figure all of this out.  Thanks


  • 16.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 18:50
    Can't seem to get mine to either trigger or work either.  I have a task table.  So wanted a webhook when a task is added, and assigned To is not equal to blank.  Then I've got API_AddRecord for a time table.
    Endpoint URL is my time record table.
    HTTP POST
    Message format XML
    Message header is QuickBase-Action and API_AddRecord

    <qdbapi>
    <usertoken>USERTOKENREMOVED</usertoken>
    <field fid="46";>[Assigned To]</field>
    <field fid="3">[Date Created]</field>
    <field fid="24">6-Administration</field>
    <field fid="34">0</field>
    <field fid="40">webhook test</field>
    </bdbapi>

    I thought maybe it was as simple as putting the fid of what I want changed in table 2 and then the values from table 1, or what i'm typing directly.


  • 17.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:03
    It looks like your closing xml element is </bdbapi> instead of </qdbapi>. I also don't know if your first line will work because of the semicolon there. Try this instead:
    <qdbapi>
    <usertoken>USERTOKENREMOVED</usertoken>
    <field fid="46">[Assigned To]</field>
    <field fid="3">[Date Created]</field>
    <field fid="24">6-Administration</field>
    <field fid="34">0</field>
    <field fid="40">webhook test</field>
    </qdbapi>


  • 18.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:08
    now see I tried both.  I had </qdbapi> first but then the example when looking at configure a webhook in QB showed </bdbapi>  lol


  • 19.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:10
    Have you looked at the error message history for the webhook.  is it not firing or is it failing?


  • 20.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:10
    I did make sure i had any "required" fields for that 2nd table.


  • 21.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:31
    Would you submit a new support case by clicking Help -> Manage Support Cases? In your description mention that the rep assigned should ask me for details and I'll be happy to help troubleshoot this for you


  • 22.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:31
    Does the endpoint URL need to be the table I want the record created on or something else?  I've got it set to the table I want the record created in.  do I leave the "?" off the end.  Can't seem to find anythign in API guide or otherwise to tell me which.


  • 23.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:33
    The endpoint URL is the table you're creating the record on. So, for your situation that's the time table


  • 24.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 12-16-2016 19:34
    Thanks!


  • 25.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 03-28-2017 22:39
    John, did you ever figure this one out?  I'm stuck in the same spot you've described above.


  • 26.  RE: How to I properly get a webhook to fire for AddRecord?

    Posted 03-28-2017 22:59
    John, i figured out the issue you ran into!  Your user token needs to be enclosed with %

    i.e. <usertoken>%USERTOKENREMOVED%</usertoken>