Zinc: Posting aString

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Zinc: Posting aString

Sean P. DeNigris
Administrator
In the Jenkins REST API, you create a new job by posting a config.xml to http://server_url/createItem?name=NewJobName

Using an existing template file was easy enough:
ZnClient new
        url: restUrl;
        queryAt: 'name' put: aString;
        uploadEntityFrom: '/path/to/config.xml';
        contentType: ZnMimeType applicationXml.
client post.

But what's the equivalent for using a string representing the file contents? I tried:
contents: JenkinsConfigFile new contents;
and
entity: (ZnEntity text: JenkinsConfigFile new contents);
but neither seemed to work... (500 error on the server)
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Zinc: Posting aString

Sven Van Caekenberghe-2
Ha, my favourite User(™),

On 12 Jun 2013, at 18:08, "Sean P. DeNigris" <[hidden email]> wrote:

> In the Jenkins REST API, you create a new job by posting a config.xml to
> http://server_url/createItem?name=NewJobName
>
> Using an existing template file was easy enough:
> ZnClient new
> url: restUrl;
> queryAt: 'name' put: aString;
> uploadEntityFrom: '/path/to/config.xml';
> contentType: ZnMimeType applicationXml.
> client post.
>
> But what's the equivalent for using a string representing the file contents?
> I tried:
> contents: JenkinsConfigFile new contents;
> and
> entity: (ZnEntity text: JenkinsConfigFile new contents);
> but neither seemed to work... (500 error on the server)

Did you pass the right content type ?

I would do either:

        client
                entity: (ZnEntity with: '<xml> .. </xml>' type: ZnMimeType applicationXml);

or

        client
                contents:  '<xml> .. </xml>';
                contentType: ZnMimeType applicationXml;

but I can't try it from here of course.

You can always add a #logToTranscript to get some more insight into what goes over the wire.

HTH,

Sven

> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Zinc-Posting-aString-tp4693047.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

--
Sven Van Caekenberghe
Proudly supporting Pharo
http://pharo.org
http://association.pharo.org
http://consortium.pharo.org





Reply | Threaded
Open this post in threaded view
|

Re: Zinc: Posting aString

Sean P. DeNigris
Administrator
Sven Van Caekenberghe-2 wrote
        client
                contents:  '<xml> .. </xml>';
                contentType: ZnMimeType applicationXml;
Thanks! That did the trick :)
Cheers,
Sean