I need some help with rest api from Processing. I’m using HTTP Request for Processing library, but I can’t get addFile() to locate my image file. Image file is saved in data folder.
Error message received: “I/O exception (java.io.FileNotFoundException) caught when processing request: image_1.jpeg (The system cannot find the file specified)”
Library reference: HTTP-Requests-for-Processing/src/http/requests/PostRequest.java at master · runemadsen/HTTP-Requests-for-Processing · GitHub
API used: https://my.plantnet.org/
My code:
import http.requests.*;
public void setup()
{
size(400,400);
smooth();
File img = new File("image_1.jpeg");
PostRequest post = new PostRequest("https://my-api.plantnet.org/v2/identify/all?api-key=MY_API_KEY_REMOVED");
post.addFile("images", img);
post.addData("organs", "['flower']");
post.send();
System.out.println("Reponse Content: " + post.getContent());
System.out.println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));
}