tag:help.appveyor.com,2012-11-13:/discussions/problems/3724-error-uploading-artifact-using-rest-apiAppVeyor: Discussion 2018-08-25T02:02:33Ztag:help.appveyor.com,2012-11-13:Comment/386013342015-12-02T19:35:09Z2015-12-02T19:35:09ZError uploading artifact using REST API<div><p>Right, it's been changed for OSS environment.</p>
<p>If there is <code>storage.googleapis.com</code> in the upload
URL then you should <code>PUT</code> file contents in the request
stream, for example:</p>
<pre>
<code> HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uploadUrl);
request.Method = "PUT";
using (var fileStream = File.OpenRead(path))
{
using (Stream reqStream = request.GetRequestStream())
{
fileStream.CopyTo(reqStream);
}
}
request.GetResponse();</code>
</pre>
<p>once the file uploaded to Google Storage you should call
"finalizing" method from the API:</p>
<pre>
<code>PUT /api/artifacts
{
"fileName": "<file_name>"
"size": <file_size_in_bytes>
}</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/386013342015-12-02T21:54:58Z2015-12-02T21:54:59ZError uploading artifact using REST API<div><p>Great, that worked a treat!</p>
<p>I've submitted a PR for updating the docs. Wasn't sure how much
detail to go into, hope it's ok. I didn't put in any example code
for the PUT to the google URL since all the other examples in that
page are in powershell, and I don't know enough powershell to be
confident I was doing it right!</p>
<p>If you want to look at my code that does this, it's here:
<a href="https://github.com/simontaylor81/Syrup/blob/939470368e100604845d2a3b806de2cfba6d41d5/SRPTests/Util/AppveyorCI.cs#L131">
https://github.com/simontaylor81/Syrup/blob/939470368e100604845d2a3...</a></p></div>Simon Taylortag:help.appveyor.com,2012-11-13:Comment/386013342015-12-02T22:16:36Z2015-12-02T22:16:36ZError uploading artifact using REST API<div><p>Looks great, thank you!</p></div>Feodor Fitsner