Trouble running APIs via Internet Explorer

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

Hi! 

I have a formula API field that I am using to run APIs to copy records from one table to another and update the existing record in the existing table.  When I run this API in Mozilla Firefox, it works fine.  When I run this API in Internet Explorer, I get an "Invalid Application Token" error.  Here is the formula that I am using:

var text URLONE=
URLRoot() & "db/bjyp32bb2?a=API_AddRecord&_fid_6="& URLEncode ([Request Type]) &
"&_fid_7="& URLEncode ([Due Date])&
"&_fid_69="&[Record ID#]&"&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it";

var text URLTWO=
URLRoot()&"db/bieyxpgq4?a=API_EditRecord&rid="&[Record ID#]& "&_fid_102="&URLEncode(Today())&"&_fid_28="&
1&"&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it";

$URLONE & "&rdr=" & URLEncode($URLTWO)


Photo of mzkorol

mzkorol

  • 0 Points

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,664 Points 50k badge 2x thumb
Your URLTWO is incorrect



URLRoot()&"db/bieyxpgq4?a=API_EditRecord&rid="&[Record ID#]

& "&_fid_102="&URLEncode(Today())

&"&_fid_28="

&1

&"&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it";




That &1 is wrong.  I'm surprised it is not a syntax error.



Try this

URLRoot()&"db/bieyxpgq4?a=API_EditRecord&rid="&[Record ID#]

& "&_fid_102="&URLEncode(Today())

& "&_fid_28=1"

& "&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it";


also its easier to debug these if you use some vertical alignment and pacing as above.
Photo of mzkorol

mzkorol

  • 0 Points
So, I made those changes, and it still didn't work.  However, when I rearranged the formula and put the app token closer to the beginning of the URL, it worked.  What I then noticed is that not all of my fields (listed in the URL) from table 1 were copied to table 2.  The last 3 were excluded, AND URL 2 did not execute.  I believe I am hitting some kind of "maximum" value, but I can't find any information as to what those maximums are.  Is it max # of fields?  Is it max number of characters?  Is it browser specific, or QuickBase imposed?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,664 Points 50k badge 2x thumb
You are far far from any limits. Can you post your current formula?
Photo of mzkorol

mzkorol

  • 0 Points
I didn't post the entire formula in the original post because I didn't think it was relevant.  Here's what I've updated the formula to be (thanks for the spacing / vertical alignment tip...I know to do that, but I'm not always as structured as I should be):

var text URLONE=
URLRoot() & "db/bjyp32bb2?a=API_AddRecord&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it&_fid_6="& URLEncode ([Request Type])
& "&_fid_7="& URLEncode ([Due Date])
& "&_fid_8="& URLEncode ([Priority])
& "&_fid_9="& URLEncode ([Assigned To])
& "&_fid_10="& URLEncode ([Customer Request])
& "&_fid_13="&[Related Project]
& "&_fid_16="&[In Progress]
& "&_fid_22=" & URLEncode ([Requested By])
& "&_fid_27="&[Pending Software Release Version]
& "&_fid_28=1"
& "&_fid_29="& URLEncode ([Accepted By])
& "&_fid_44="&[Waiting for Customer Validation]
& "&_fid_47="&[Actual Hours Spent]
& "&_fid_48="&[Site Asset Number]
& "&_fid_52="&[Tech Request Start Date]
& "&_fid_53="&[Clinical Request]
& "&_fid_56="&[Standard LOE (Editable)]
& "&_fid_76="&[TR Request During]
& "&_fid_62="&[Revised Due Date]
& "&_fid_65="&[Related Contact]
& "&_fid_86="&[Axeda Asset]
& "&_fid_87="&[Version of the Application]
& "&_fid_88="&[Solutions Support Activity]
& "&_fid_89="&[Browser Used]
& "&_fid_93="&[ServiceMax Case #]
& "&_fid_90="&[Affected User(s)]
& "&_fid_69="&[Record ID#];

var date datemoved = ToDate(Now());

var text URLTWO=
URLRoot()&"db/bieyxpgq4?a=API_EditRecord&apptoken=dsiwu2jcqp3vrkbmer7hrc28h4it&rid="&[Record ID#]
& "&_fid_28=1"
& "&_fid_102="& $datemoved;

$URLONE & "&rdr=" & URLEncode($URLTWO)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,664 Points 50k badge 2x thumb
I suspect what is happening is that there are some illegal characters in the URL which is breaking the formula at some point.  For example if the field value for [Browser Used] has the value in the data of "IE #10", the space and the # could confuse the URL.  That is why you URLEncode, so I suggest that you URL any fields which may contain unpredictable data which is not pure A-Z and 0-9 characters, no spaces either.

You seemed to be URLEncoding at the beginning, but then seemed to lose the pattern
Photo of mzkorol

mzkorol

  • 0 Points
Thank you!  Thank you!  That worked, and now I feel foolish for not URLEncode -ing everything from the start.  This is what happens when you ask a Myers Briggs personality type ENTP to write code!  Great ideas on how to make things work, but not enough structure or attention to detail.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,664 Points 50k badge 2x thumb
... so a happy ending to a Friday afternoon.