runemadsen / HTTP-Requests-for-Processing

http://www.runemadsen.com
MIT License
140 stars 39 forks source link

Help me !! #42

Open RodysRod opened 3 years ago

RodysRod commented 3 years ago

Hello I'm trying to use a json's post but the addData function doesn't understand json to compose the request, I tried the example that is available, but an error appears (the "addData" function expects parameters like "addData (String, String)" in my http server along with my api in the postman is working, I wanted to test with processing, could help me. ErrorPostJson

JonasGruenwald commented 3 years ago

Well like it says, you're supplying a single string with some stuff inside but the function expects two strings like this, first being the key and second being the value:

post.addData("on","false");
RodysRod commented 3 years ago

Bem, como diz, você está fornecendo uma única string com algumas coisas dentro, mas a função espera duas strings como esta, a primeira sendo a chave e a segunda sendo o valor:

post.addData("on","false");

Well, nice to try to clarify, but it is a json like the one described in the header, it is not just a text, the point is that at the root of the processing it does not understand the {} keys if they are used without "" as in a structure is understood as a void {}.

JonasGruenwald commented 3 years ago

Ah ok, I guess you are basing this on the overloaded addData function here in the source ? https://github.com/runemadsen/HTTP-Requests-for-Processing/blob/master/src/http/requests/PostRequest.java#L71 since it's nowhere in the documentations or examples, I guess it is not in the current release... but if you just copy it over from the source into your processing project it should work just fine

Screenshot 2021-01-06 at 23 09 22
RodysRod commented 3 years ago

Ah ok, I guess you are basing this on the overloaded addData function here in the source ? https://github.com/runemadsen/HTTP-Requests-for-Processing/blob/master/src/http/requests/PostRequest.java#L71 since it's nowhere in the documentations or examples, I guess it is not in the current release... but if you just copy it over from the source into your processing project it should work just fine

Screenshot 2021-01-06 at 23 09 22

Thanks for the help, but even changing it at the root I didn't get a positive result. Capturar1

JonasGruenwald commented 3 years ago

Ah right, I didn't change it at the root or anything, don't even know where library files are stored in processing, I just meant not importing the library but copying that specific class (PostRequest) from the source into a different tab in your processing project just like that to make it work, it does work for me. Just as a temporary workaround, obviously ideally they would release a new version with the overloaded function included.

Screenshot 2021-01-07 at 00 14 03
RodysRod commented 3 years ago

Ah right, I didn't change it at the root or anything, don't even know where library files are stored in processing, I just meant not importing the library but copying that specific class (PostRequest) from the source into a different tab in your processing project just like that to make it work, it does work for me. Just as a temporary workaround, obviously ideally they would release a new version with the overloaded function included.

Screenshot 2021-01-07 at 00 14 03

Thank you very much, it worked the way you gave it to me.