
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
ALM REST upload attachment - internal server error (500)
hi there,
i try to upload an attachment to a defect.
I always get an error internal server error (500).
This is the request stream i send, and for me it looks ok.
Has anyone an idea what might be the problem?
c# code
string boundary = "uploadboundary";
string URL = "http://server/qcbin/rest/domains/DOMAIN/projects/PROJECT/attachments";
HttpWebRequest attRequest = (HttpWebRequest)WebRequest.Create(URL);
attRequest.Method = "POST";
attRequest.ContentType = "multipart/form-data; boundary=" + boundary;
attRequest.Accept = "application/json";
attRequest.CookieContainer = authRequest.CookieContainer;
string FilePath = "test.txt";
formData.Clear();
formData["entity.type"] = "defect";
formData["entity.id"] = "825";
formData["filename"] = "test.txt";
formData["description"] = "Testanhang";
Stream postDataStream = GetPostStream(FilePath, formData, boundary);
attRequest.ContentLength = postDataStream.Length;
Stream reqStream = attRequest.GetRequestStream();
postDataStream.CopyTo(reqStream);
postDataStream.Close();
reqStream.Close();
HttpWebResponse attResponse = (HttpWebResponse)attRequest.GetResponse();
reqstream:
--uploadboundary
Content-Disposition: form-data; name="entity.type";
defect
--uploadboundary
Content-Disposition: form-data; name="entity.id";
825
--uploadboundary
Content-Disposition: form-data; name="filename";
test.txt
--uploadboundary
Content-Disposition: form-data; name="description";
Testanhang
--uploadboundary
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain
das ist ein test
--uploadboundary--

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi
Attachments are not part of the public API as stated in the documentation here: http://octane-help.saas.hpe.com/en/12.55.3/API/Developer_Help.htm#API/Attachments.htm
That means that you need to send a special header in order for the attachments to work.
If you are still having issues after adding the header please let me know
Spencer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
Could we perhaps send e.g. error 403 with an explanation instead?
Thanks,
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This is a possibility - however it does depend on what actually happened. We would have to see further details about what exactly the problem is in this case
Spencer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Spencer,
thank you for the info. No clue how to find it. In the offical rest api documentation is another description.
Anyway, I still have the same error. Hopefully cou can help me again.
KR
Bernd
POST /qcbin/rest/domains/CUSTOMER/projects/PROJECT/attachments HTTP/1.1
Content-Type: multipart/form-data; boundary=--uploadboundary
Accept: application/json
HPCLIENTTYPE: HPE_REST_API_TECH_PREVIEW
Host: msapp02p:8080
Cookie: LWSSO_COOKIE_KEY=IpX30bApPSUEUnP4Uq9IwSNbcdI89VgnNg5ISV3amF-1F2lqplnJblqtcrGOiM19JZrsJtZmtkFXpVVYKay9B-MEipAUhWaS7BOzjnj2ZlMe3ZHHZBCeSVY9Sbv-Bi8mfGUSkKp-mipMVsqbxt0tmf0kDvr3Hc7D707YUPwEnNVQLG4OgM714VtWyRVRDwzuqg0m6qWk1uHosNetQYd9QoWsasbUoPzq4cSm-iUnNPQR3mF7HyVf5HXULHJR89DaMqG42K6J7tCMZZjdOCcFNisBJNLSqHYckdJL-dV7k5s.; QCSession=NjMyOTc3O0prRVRIdWRUb2JTdmpacE8xN1dzRVEqKjtSRVNUIGNsaWVudDsgOyA.; ALM_USER=72cbc27efa8f4f748a37d85b07d99f9a31ec7e677ae6f4e1cec9425451e63a21; XSRF-TOKEN=3e9858df8e7be714dbda3127dafb7b26eaa71fbe364fe74ede0737a21a0358a4
Content-Length: 398
Expect: 100-continue
--uploadboundary
Content-Disposition: form-data; name="entity"
Content-Type: application/json; charset=UTF-8
{"owner_defect":{"id":846, "type":"defect"}, "name":"test.txt", "description":"Testanhang"}
--uploadboundary
Content-Disposition: form-data; name="content"; filename="test.txt"
Content-Type: text/plain
Content-Transfer-Encoding: base64
ZGFzIGlzdCBlaW4gdGVzdA==
--uploadboundary--
HTTP/1.1 500 Server Error
Date: Tue, 29 Aug 2017 14:38:56 GMT
X-Content-Type-Options: nosniff
Set-Cookie: LWSSO_COOKIE_KEY=Aaip8XXCQVxA3y8H5xAMp6Qq_qZPK1AW4Ga-QA6E_Ga2xFfdz-XuxgAKVz1gX0nUN1nlEbZbk0DN55G5BclxrmLkzJQT3spyI7Yd90cqpDDsPUFWMfU1r0h7GEf4AtIwaX7p-X26oRw5gDCugM3sau3HOwFNTh8IaZYdTI8mF0VpU4Jm0gHWnO3fQKVByBz7uw3eFWnqpEsV48Uagt01hhtV_u1jZp4DcwwaHyuP_PXwEGU4qi82-v2XG9a4OmluqCjLSFCKl2zCRhW9-1QES8kgXqopOgpb9U1E9FDFfBQ.;Path=/;HTTPOnly
Set-Cookie: JSESSIONID=2z8qhiduso8x1afvtp8zaw4ep;Path=/qcbin;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json
X-XSS-protection: 1; mode=block
Content-Length: 114
Server: Jetty(9.1.4.v20140401)
{"Id":"qccore.general-error","Title":"String index out of range: -1","ExceptionProperties":null,"StackTrace":null}