Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




WebService - adding an attachement to the existing issue. HOW?

web-app

Hello,

I'm trying to add attachement to the existing issue. I took the code from the other post: Web Services - Creating attachments but neither IssueServices.UpdateIssue() or IssueServices.UpdateFullIssue() add the attachement to the issue. What is the right way to do this?

        public void AddIssueAttachement(IssueEN issue, string fileAbsPath, string shortFileName)
        {
            FileEN[] files = new FileEN[1];
            files[0] = new FileEN();

            System.IO.FileInfo attachment = new System.IO.FileInfo(fileAbsPath);

            byte[] bytes;
            using (FileStream fs = attachment.OpenRead())
            {
                bytes = new byte[fs.Length];
                fs.Read(bytes, 0, (int) fs.Length);
            }

            files[0].FileData = bytes;
            files[0].ContentType = "image/jpeg";
            files[0].ContentLength = bytes.Length;
            files[0].FileName = shortFileName;
            files[0].ProjectID = issue.ProjectID;
            files[0].IssueID = issue.IssueID;

             // other user said null or 0 doesn't work for him.
             // but commenting the line below doesn't help either.
            files[0].CommentID = 12;  


            issue.Attachments = files;

            Manager.IssueServices.UpdateIssue(issue);
            // Manager.IssueServices.UpdateFullIssue(issue);
    }



Thank you.

avs099
· 1
avs099
Replies (4)
helpful
0
not helpful

Did you try setting the comment id to null and using UpdateFullIssue? do you get errors?

Do you have permissions to update an issue?

Also, try setting the EntityState property to New.


Saar Cohen
· 5000
Saar Cohen
helpful
0
not helpful

Hello,

thanks for the prompt reply.

1. I tried setting CommentID both to null and non-null values - I don't get errors but neither works.

2. I do have permissions to update issue - I'm logging in as Admin, and I can add comments, view projects etc via WebService.

3. I tried to set Issue.State = New, but that did not help.


Would appreciate any solution to this problem.


Thanks again.


avs099
· 1
avs099
helpful
0
not helpful

You need to set the attachment (FileEN) state to new:

IssueEN data=msmProxyManager.IssueServices.GetIssue((int)numProjectID.Value,(int)numID.Value);

data.IssueLongDesc=txtDesc.Text;

data.IssueSummary=txtTitle.Text;

FileEN[] files = new FileEN[1];

files[0] = new FileEN();

files[0].CommentID = null;

System.IO.FileInfo attachment = new System.IO.FileInfo("c:\test.txt");

System.IO.FileStream fs = attachment.OpenRead();

byte[] bytes = new byte[fs.Length];

fs.Read(bytes, 0, (int)fs.Length);

fs.Close();

files[0].ContentLength = bytes.Length;

files[0].ProjectID = data.ProjectID;

files[0].FileData = bytes;

files[0].FileName = "testatt";

files[0].State = BaseEN.EntityState.New;

data.Attachments = files;

msmProxyManager.IssueServices.UpdateFullIssue(data);


Mark Wing
· 9108
Mark Wing
helpful
0
not helpful

that helped, thanks a lot!!


avs099
· 1
avs099