How to send HTTP-PUT-request?

Hello all,

I am trying to make use of the REST interface in processing,

I am currently using the "HTTP Requests for Processing" and I'm successfully able to read the information I want using the GET method, but what I really need is to send a PUT request. Ideally I would like something equivivalent to p5.js's function httpDo().

I am a bit new to web-programming, especially in processing. Can anyone please point me in the right direction, be it a library or another form discussion I would appreciate it greatly,

Thanks in advance!

Tagged:

Answers

  • Answer ✓

    that library allows GET and POST only. it's pretty basic.

    i have a patched version here that allows PUT (see bottom of readme): https://github.com/acdean/HTTP-Requests-for-Processing

    the whole thing needs doing properly, really.

  • Thanks @koogs! I haven't had time to keep the library up to date, but would love to fix it up this summer. If you'd like to pull request stuff please feel free!

  • What other things are needed in this library @koogs? Could you comment in the current status, what it does well currently, what could be improved and what other concepts should be implemented?

    Kf

  • oh, i've been adding bits to it as people here have wanted them so it's all gone a bit organic (see the PUT kludge). other people have added other interesting bits (oauth did i see?) and i wouldn't like to have to merge them back together now.

    if i was doing it from scratch i'd have an input class and an output class and GET, HEAD, DELETE etc would extend the input class, PUT and POST would extend the output class.

    methods to add data to the request as either request params or body data. the latter as name / value pairs, binary content, binary content from a file, string content etc (json, xml). and headers. i think my version might have a lot of these already but not in any well-designed way 8)

  • i'd also get rid of all the tabs in the source files.

  • Thanks for the help all :)

  • edited May 2018

    Hi all. I can't seem to download a version of the HTTP library that allows PUT usage.

    I have followed the koogs link above but the download does not give me a full library i can use. I have merged what is downloaded with the current HTTP library too but still it will not allow PUT.

    Any ideas? Thanks

    put.method("PUT");

    produces the error: The function "method(String)" does not exist.

  • just drag the java file into the pde editor and it should do the right thing

  • (it's not my library so i can't easily add the updates to it but i can probably do something better than the above, preferably with the aforementioned updates)

  • Thanks koogs. That seems to have got it working.

    Now just to figure out if i can use PUT to update my file in WordPress Uploads folder... seems that it doesnt quite work like POST.

Sign In or Register to comment.