cancel
Showing results for 
Search instead for 
Did you mean: 

Rest API Attachment issue:

Occasional Contributor

Rest API Attachment issue:

Dear all,

 

I have been working with the integration of TestComplete with YouTrack.

so far i have been successful with creating a new issue in youtrack through a test run from testcomplete.

however, the issue i am still facing is uploading the attachment along with creating the issue.

any help would be great.

below is my code:

 

function httpPostRequest()
{
project=ABC&summary=new+issue&description=description+of+new+issue";
var address = "http://URL/rest/issue?project=ABC&summary=new+issue&description=Description+of+new+issue&attachment=D:\\Newfolder\\b.jpg";
var username = "user@abc.com";
var password = "userabc";

var requestBody = '1';

var aqHttpRequest = aqHttp.CreatePostRequest(address, username, password);

aqHttpRequest.SetHeader("Content-Type", "application/json");
var aqHttpResponse = aqHttpRequest.Send()

Log.Message(aqHttpResponse.StatusCode); // A status code
Log.Message(aqHttpResponse.Text); // A body

aqHttpResponse.SaveToFile("D:\\Postbody.txt");

}

 

this creates the issue but does'nt upload the attachment.

1 REPLY 1
Community Hero

Re: Rest API Attachment issue:

Hi,

 

File upload via http is a complex process. E.g.: https://stackoverflow.com/questions/8659808/how-does-http-file-upload-work

I never used YouTrack, but still I think that this should be a two-step process:

-- You need to create an issue first and get its id or whatever is required to address the issue in the future;

-- The second step is to use some other API call that will upload the file from your local system to the server and link uploaded file to the issue.

 

So I would suggest to search for an API that uploads the file and links it to the already existing issue.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
New Here?
Join us and watch the welcome video:
Top Kudoed Authors