I am trying to create a method that logs to a server, grabs the json file it found, then selects 4 of each element and sends it to an address. My code below seems to work when I give it only a single data known for each format in the send link rather than a loop that should select each at a time. The error I'm getting is: instance of smallInteger did not understand #readStream
. What is causing this error? How else can I automate these requests?
1 to: 4 do: [ :each |
each.
a := ZnClient new.
a get: 'https://MyServer/'.
a headerAt: 'referer' put: 'https://MyServer' ;
formAt: 'email' add: 'myEmail' ;
formAt: 'password' add: 'MyPass'.
a post.
a get: 'https://MyServer/json'.
data := NeoJSONReader fromString: a contents.
list := data at: each.
foo := list at: 'num'.
poo := list at: 'name'.
a get: 'https://MyServer/copy/', poo.
a url: 'https://MyServer/send/'.
a formAt: 'add' add: 'given address' ;
formAt: 'nb_pic' add: foo ;
formAt: 'identf' add: poo.
a post.
a get: 'https://MyServer/json' ]
At first sight, there is nothing wrong with the syntax.
But looks like you didn't get the API of the framework you are using: you send
get
andpost
messages without understand that they will actually execute a "http get" and "http post" each time you send them.So, while the "syntax" it self is ok, what is very incorrect is what you are doing (Which I do not understand what is). Look, this is how your program can be understood:
clearly, that code is not doing what you want it to do :)