Sitecore.Ship icon indicating copy to clipboard operation
Sitecore.Ship copied to clipboard

/services/publish/listofitems gets a 404, when trying to publish a list of items

Open sgisbert opened this issue 9 years ago • 8 comments

Hi!

I'm using your great tool to try to automate Sitecore 7 & 8 deployments, and I'm having a strange issue at the latest step: publishing the installed items is returning a 404 error. My whole stack is TeamCity + Courier + Ship 0.4.0 (I've cloned your source code).

I have the items package created with Sitecore Courier. I've created a simple command line tool that has 2 tasks:

  • Install the package to "/services/package/install/fileupload" and get the list of installed items.
  • Create the Items-To-Publish list and post it to "/services/publish/listofitems".

First step works fine, and I get the list, but when I post to do the publishing, I'm getting a 404.

This is the source code to POST the publishing:

    private static void PublishItems(PublishItems items, string targetUrl)
    {
        try
        {
            // Create a request using a URL that can receive a post. 
            WebRequest request = WebRequest.Create(targetUrl + "/services/publish/listofitems");

            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Create POST data and convert it to a byte array.
            string postData = items.ToJson();
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();
            // Get the response.
            WebResponse response = request.GetResponse();
            // Display the status.
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            // Display the content.
            Console.WriteLine(responseFromServer);
            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

This is a sample POST, as captured in Fiddler:

POST http://sitecore8target/services/publish/listofitems HTTP/1.1 Content-Type: application/x-www-form-urlencoded Host: sitecore8target Content-Length: 366 Expect: 100-continue

{"Items":[{"itemId":"662a3670-2671-414c-97e5-f9b30473cdd7","PublishChildren":"false"},{"itemId":"a49599a5-1b25-4efe-82aa-fa1af0993919","PublishChildren":"false"},{"itemId":"377cb37e-2b00-417e-bbec-872b4ef9e9a0","PublishChildren":"false"},{"itemId":"9502a1e1-7bdd-4b3e-a234-a488ba871889","PublishChildren":"false"}],"TargetDatabases":["web"],"TargetLanguages":["en"]}

And the 404 error: image

The Sitecore instance at "http://sitecore8target" has Ship 0.4.0 installed, and the Install package service works as expected.

Any ideas where to look at? Many thanks in advance!

Sergi

sgisbert avatar Aug 18 '15 15:08 sgisbert

Tried also with curl with same results:

curl -H "Content-Type: application/json" -X POST -d "{"Items":[{"itemId":"662a3670-2671-414c-97e5-f9b30473cdd7","PublishChildren":"false
"},{"itemId":"a49599a5-1b25-4efe-82aa-fa1af0993919","PublishChildren":"false"},{"itemId":"377cb37e-2b00-417e-bbec-872b4ef9e9a0","PublishChildren":"false"},{"itemId":"9502a1e1-7bdd-4 b3e-a234-a488ba871889","PublishChildren":"false"}],"TargetDatabases":["web"],"TargetLanguages":["en"]}" http://sitecore8target/services/publish/listofitems --proxy 127.0.0.1:8888

sgisbert avatar Aug 18 '15 15:08 sgisbert

@sgisbert Just looking at it now with POSTman and seem to be getting the same results as you.

I'll get back to you Sergi as quickly as possible.

kevinobee avatar Aug 18 '15 16:08 kevinobee

Thanks Kevin. Awesome news. Looking forward to your results.

sgisbert avatar Aug 18 '15 16:08 sgisbert

@sgisbert which NuGet package are you using for Ship?

kevinobee avatar Aug 18 '15 16:08 kevinobee

Sitecore.Ship.AspNet.0.4.0.nupkg, the one generated with the build.

sgisbert avatar Aug 18 '15 16:08 sgisbert

@sgisbert OK, so that it the HTTP handler version rather than the package based around NancyFx.

I'll focus on that codebase then.

kevinobee avatar Aug 18 '15 16:08 kevinobee

Created a pull request with a potential fix: https://github.com/kevinobee/Sitecore.Ship/pull/46

sgisbert avatar Aug 21 '15 13:08 sgisbert

I have the same issue, any news on a fix? /services/about reports: Sitecore.Ship - version 0.4.0.0 as my version.

millusdk avatar Jun 28 '16 09:06 millusdk