Error in attachment upload

RESOLVED FIXED

Status

RESOLVED FIXED
9 years ago
2 months ago

People

(Reporter: adrianocola, Assigned: gerv)

Tracking

Trunk
x86
Linux

Details

(Reporter)

Description

9 years ago
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
(Reporter)

Comment 2

9 years ago
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
(Reporter)

Comment 4

9 years ago
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
Last Resolved: 9 years ago
Resolution: --- → FIXED

Updated

2 months ago
Product: Webtools → Webtools Graveyard
You need to log in before you can comment on or make changes to this bug.