Hello,
Sorry for asking so much questions but I lost the big picture right now.
Im trying to get the response object back from a api call.
That I can do with :
response := ZnEasy get: url.
and I see that it has the fields statusline which has the field code
I thought I could use it like this : response at: #statusline `
but that give me a error message that indexes needs to be integers.
How do I get the code field again ?
Roelof
You really should read the HTTP chapters of http://books.pharo.org/enterprise-pharo/
not just the Web App chapters.
Also, any general introduction to HTTP (maybe even https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) will help you.
You can just say
response statusLine
You also really, really have to learn how to use the tools (the IDE) to help yourself. If you browse the ZnResponse class, you can see all this for yourself. I know there is a steep learning curve, and that it can be intimidating, but the whole idea behind Pharo is that you have this living object system that you can explore and learn from.
The introduction texts (Pharo By Example, the MOOC, etc) all try to learn you that.
Use spotter to find things, use browsers to look at code, use inspectors to look at objects, use senders and implementers, use class references, read class and method comments, study unit tests. Learn from the system.
BTW, ZnEasy is just a simple class side facade, ZnClient is the real thing.
On 28 Sep 2020, at 20:34, Roelof Wobben via Pharo-users pharo-users@lists.pharo.org wrote:
Hello,
Sorry for asking so much questions but I lost the big picture right now.
Im trying to get the response object back from a api call.
That I can do with :
response := ZnEasy get: url.
and I see that it has the fields statusline which has the field code
I thought I could use it like this : response at: #statusline `
but that give me a error message that indexes needs to be integers.
How do I get the code field again ?
Roelof
Op 28-9-2020 om 21:11 schreef Sven Van Caekenberghe:
<pre class="moz-quote-pre" wrap="">You *really* should read the HTTP chapters of <a class="moz-txt-link-freetext" href="http://books.pharo.org/enterprise-pharo/">http://books.pharo.org/enterprise-pharo/</a> in particular <a class="moz-txt-link-freetext" href="https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Zinc-HTTP-Client/Zinc-HTTP-Client.html">https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/Zinc-HTTP-Client/Zinc-HTTP-Client.html</a> not just the Web App chapters. Also, any general introduction to HTTP (maybe even <a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol</a>) will help you. You can just say response statusLine You also really, really have to learn how to use the tools (the IDE) to help yourself. If you browse the ZnResponse class, you can see all this for yourself. I know there is a steep learning curve, and that it can be intimidating, but the whole idea behind Pharo is that you have this living object system that you can explore and learn from. The introduction texts (Pharo By Example, the MOOC, etc) all try to learn you that. Use spotter to find things, use browsers to look at code, use inspectors to look at objects, use senders and implementers, use class references, read class and method comments, study unit tests. Learn from the system. BTW, ZnEasy is just a simple class side facade, ZnClient is the real thing.
Thanks,
I think this could help me :
ZnClient new
enforceHttpSuccess: true;
ifFail: [ :ex | self inform: 'Cannot get numbers: ', ex printString ];
get: '<a class="moz-txt-link-freetext" href="http://zn.stfx.eu/zn/numbers.txt">http://zn.stfx.eu/zn/numbers.txt</a>'.
I will try it tomorrow after some sleep
Roelof