Not able to attach file to ticket using API

59 views
Skip to first unread message

shaveta sharma

unread,
Apr 27, 2017, 10:49:14 PM4/27/17
to Assembla API Development

Apr 25
I am not able to attach file to existing ticket.

I am getting following error :-

HTTP status: 500{"status":"500","error":"Internal Server Error"}

URL used is:-
http://api.assembla.com/v1/spaces/gpsi-internal-projects/documents.json

Data posted in JSON is:-
$postData['document'] = array(
'ticket_id'=>'1136',
'name'=>'success.png',
'file'=>$data['file'],
);


In ticket id I have tried with both ticket number and ticket ID, but no success.

Regards
Shaveta
Auto Generated Inline Image 1

Stanislav Kolotinskiy

unread,
Apr 28, 2017, 9:34:24 AM4/28/17
to shaveta sharma, Assembla API Development
Hi Shaveta,

here is how I’m attaching a document to the ticket:

curl -i -XPOST -H "X-Api-Key: _" -H "X-Api-Secret: _" -H "Content-Type: multipart/form-data" "https://api.assembla.com/v1/spaces/_space_id/documents.json" -F "document[file]=@/path/to/file" -F "document[name]=file.ext" -F "document[ticket_id]=_ticket_id" -F "document[attachable_id]=_ticket_id" -F "document[attachable_type]=Ticket"
HTTP/1.1 100 Continue

HTTP/1.1 201 Created
Date: Fri, 28 Apr 2017 13:31:38 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d653ffdb64659c21d00e94ac222fb5fbc1493386297; expires=Sat, 28-Apr-18 13:31:37 GMT; path=/; domain=.assembla.com; HttpOnly
Cache-Control: max-age=0, private, must-revalidate
X-XSS-Protection: 1; mode=block
X-Log-Plan-Paid-At: 2016-02-05 01:33:47
X-Request-Id: 0a850c7a-3c01-4bab-9d2d-c11d1ddbf1b5
ETag: W/"b865c223b572a1e652a04b97b0d634e7"
X-Frame-Options: SAMEORIGIN
X-Runtime: 0.526502
X-Content-Type-Options: nosniff
X-Powered-By: Phusion Passenger 5.0.28
Status: 201 Created
Server: cloudflare-nginx
CF-RAY: 356a6204e9112908-OTP

{reply here}

Please let me know if that helps.

Regards,
Stanislav

On Apr 28, 2017, at 05:49, shaveta sharma <sharma.s...@gmail.com> wrote:


<Auto Generated Inline Image 1.png>
Apr 25

--
You received this message because you are subscribed to the Google Groups "Assembla API Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-d...@googlegroups.com.
To post to this group, send email to assembla...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<Auto Generated Inline Image 1.png>

Stanislav Kolotinskiy

unread,
May 1, 2017, 4:03:06 AM5/1/17
to shaveta sharma, Assembla API Development
Hi Shaveta,

I just realized that you are passing ticket number instead of ticket id, that’s why it’s throwing a 500. I’ll fix the call so that it returns 422 with a better explanation instead.

Regards,
Stanislav

Simrat Pal Singh

unread,
May 5, 2017, 7:48:15 AM5/5/17
to Assembla API Development, sharma.s...@gmail.com
Hi Stanislav,

I am Simrat and working with Shaveta on this task. We are using the ticket id in the request not the ticket number and still getting the 500 internal server error if request using PHP CURL post. However, if I use the command that you have provided above using the command line, I am successfully able to attach the file to the ticket. I have attached the code we are using for the file attachment. 

We have tried every possible solution for this but not able to solve this problem. It would be helpful if you can return the actual error instead of 500 internal server error. Or if you have any sample PHP code for file attachment, please provide that to us.

Thanks,
Simrat
assembla_attachment.php

wojc...@assembla.com

unread,
May 5, 2017, 3:07:11 PM5/5/17
to Assembla API Development, sharma.s...@gmail.com
Hi Simrat,

Take a look on your script : 'file'=>'@D:\xampp\htdocs\tt-lms\app\webroot\images/test.jpg', 
I think it should be 'file'=>'@D:\xampp\htdocs\tt-lms\app\webroot\images\test.jpg
From what I see our script don't recognize correct path here and getting issue during upload. 
We will investigate it further.

Regards,
Wojciech

Simrat Pal Singh

unread,
May 12, 2017, 8:07:55 AM5/12/17
to Assembla API Development, sharma.s...@gmail.com
Wojciech,

We have tried to set the path in both ways, but getting the same issue.
'file'=>'@D:\xampp\htdocs\tt-lms\app\webroot\images\test.jpg'
'file'=>'@D:\xampp\htdocs\tt-lms\app\webroot\images/test.jpg'

Please look into this issue on priority.

Thanks,
Simrat

wojc...@assembla.com

unread,
May 15, 2017, 7:12:42 AM5/15/17
to Assembla API Development, sharma.s...@gmail.com
Hi Simrat, 

You are not building query correctly for nested params. Please check : https://bugs.php.net/patch-display.php?bug_id=67477&patch=add-http_build_query_develop-function&revision=latest and use mentioned function. or http://php.net/manual/en/class.curlfile.php.

also using CurlFile file instead of @ notation should be safer.  We are going to fix file param validation shortly and return correct error.

Regards,
Wojciech

Simrat Pal Singh

unread,
May 15, 2017, 9:22:23 AM5/15/17
to Assembla API Development, sharma.s...@gmail.com
Hi Wojciech,

It worked for me, thanks for the help.

Thanks,
Simrat
Reply all
Reply to author
Forward
0 new messages