Skip to main content
Question

Delete File Attachment with API_EditRecord

  • June 7, 2014
  • 0 replies
  • 213 views

I have to be missing something here. Cannot delete a file attachment through the API_EditRecord. tried passing these

_fid_120=false

_fid_120=

_fid_120=0


Any obvious suggestions??



This topic has been closed for replies.

  • Registered
  • June 7, 2014
It is undocumented but you have to specify two parameters for each file attachment you want to delete. In the URL below we are deleting the file saved in the file attachment field with fid=9 and [Record ID#]=43. Here is the format of the unwound URL for a GET request:

https://<your subdomain>.quickbase.com/db/<your dbid>

?act=API_EditRecord

&rid=43

&_fid_9=

&delfile_fid_9=1

&apptoken=<your apptoken>

The pastie entry below shows a POST using a jQuery promise that accomplishes the same thing:

Pastie Database

https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=285


This was not obvious so its time for a celebratory song:

http://dualcoremusic.com/nerdcore/upload/dual_core-trust_me.mp3

Wow, how did you figure that one out?

  • Registered
  • June 7, 2014
I have connections:

http://goo.gl/jKwGHq

  • Author
  • Registered
  • June 10, 2014
Thank you!  ~singing~

  • Registered
  • June 11, 2014
Hi, thanks in advance, but what if I just wanted to make a button that deleted the file attachment on whichever record id I was viewing? for example -- I have a Table called 'Brady Bunch', and there are 6 rids so far -- each record id  has a picture of that child uploaded to it: Greg (rid_1), Marsha (rid_2), Peter (rid_3), Jan (rid_4), Bobby (rid_5), Cindy (rid_6).

Question 1:
I won't know which attachment I want to delete until I get on the actual record. How can I do this in the API script so the rid is more of a variable?

Question 2:
Where are you getting the update ID from?

Question 3:
When I save, it's telling me I need a 'Type'

Let me know when/if you have a moment?

Thanks!

  • Registered
  • November 12, 2016
Because someone else might come along looking for this: here's the XML version:

<qdbapi>
<udata>mydata</udata>
   <ticket>auth_ticket</ticket>
   <apptoken>app_token</apptoken>
     <rid>[record_id]</rid>
  <field fid="[field_id]" filename="delete"></field>
</qdbapi>

I also added it to my copy of the PHP API wrapper as a modification of API_Edit:

public function delete_file($rid, $fid) {
  if($this->xml) {
    $xml_packet = new SimpleXMLElement('<qdbapi></qdbapi>');
    $xml_packet->addChild('rid',$rid);
    $xml_packet->addChild('field','');
    $xml_packet->field[0]->addAttribute('fid',$fid);
    $xml_packet->field[0]->addAttribute('filename','delete');

    if ($this->app_token)
      $xml_packet->addChild('apptoken', $this->app_token);
    $xml_packet->addChild('ticket',$this->ticket);
    $xml_packet = $xml_packet->asXML();
    $response = $this->transmit($xml_packet, 'API_EditRecord');
  }
  if($response) {
    return $response;
  }
  return false;
}