Closed Bug 534941 Opened 15 years ago Closed 15 years ago

Error in attachment upload

Categories

(Webtools Graveyard :: BzAPI, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: adrianocola, Assigned: gerv)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10
Build Identifier: 0.3

Tried to attach a text using the base64 text "dGVzdGUgdGV4dG8=" in the data attribute and got the following error:

Dec 15 17:42:43 [ERROR] Caught exception in Bugzilla::API::Controller::Bug->attachment "Can't use string ("dGVzdGUgdGV4dG8=") as a HASH ref while "strict refs" in use at /var/www/bzapi/script/../lib/Bugzilla/API/Model/Attachment.pm line 196."

Other atributes used:
file_name="test.txt"
description="text.txt"
encoding="base64"
content_type="text/plain"
is_obsolete="0"
is_patch="0"
is_private="0"
token=<token received from get BUG>



Reproducible: Always

Actual Results:  
Error in bzapi.log

Expected Results:  
Attached file in BZ

BZ 3.4.4 with patches required for bzapi
Please can you supply the exact JSON you are submitting?

It should look something like this:

{
  "data": "dGVzdGUgdGV4dG8=",
  "file_name": "test.txt",
  "description": "text.txt",
  "encoding": "base64",
  "content_type": "text/plain",
  "is_obsolete": "0",
  "is_patch": "0",
  "is_private": "0",
  "token: "<token received from get BUG>"
}

(including the curly brackets).

Gerv
I'm using XML.

Used the following statement:

<attachments file_name="test.txt" description="text.txt" encoding="base64" content_type="text/plain" is_obsolete="0" is_patch="0" is_private="0" token="<token received from get BUG>"></attachments>

Didn't received any parsing error with the above XML
The XML interface is not at all supported, but a good rule of thumb is that you should put in what you get out.

If I visit:
https://api-dev.bugzilla.mozilla.org/0.4/attachment/12345?attachmentdata=1&content-type=application/xml
I get:
<opt>
  <data id="12345" bug_id="47524" bug_ref="https://api-dev.bugzilla.mozilla.org/0.4/bug/47524" content_type="text/plain" creation_time="2000-08-03T22:18:00Z" data="MFs3YjFhNzB..." description="smtp log, new profile, no activation, send then crash" encoding="base64" file_name="smtp.log" is_obsolete="0" is_patch="0" is_private="0" is_url="0" last_change_time="2000-08-03T22:18:57Z" ref="https://api-dev.bugzilla.mozilla.org/0.4/attachment/12345" size="1995">
    <attacher name="trudelle" />
  </data>
</opt>


That looks a bit different to your XML. Cutting it down to what you'd need for a new attachment submission, you end up with:

<opt>
  <data content_type="text/plain" description="test.txt" data="dGVzdGUgdGV4dG8=" encoding="base64" file_name="test.txt" is_obsolete="0" is_patch="0" is_private="0" is_url="0" />
</opt>

Gerv
Now working! =D

Just did what you told. Funny is that with the other elements it worked sending anything as the XML node. To send bugs I just used one single XML root node "<bug/>".

Thank you!
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.