Please, help me. API Post method, I want to solve it

API pdf file :

import http.requests.*;

public void setup(){
  PostRequest post = new PostRequest("https://getefento.com/"); // api/v2/measurements
  post.addHeader("Content-Type", "application/json");
  post.addHeader("charset", "UTF-8"); 
  post.addHeader("X-ApiToken", "----");
  post.addHeader("serial", "[string]");
  post.send(); 
  
  println(post.getContent()); 
  
  noLoop();
  
}

public void draw(){
  
}

I can’t solve it even if I put this and that source code.

If you know how to fix, please help.

I try to write the source code while viewing the pdf file, but I cannot receive the data.

Hi,

Can you describe your issue more precisely? What are you trying to do? What doesn’t work?

Providing a Google drive link is not the best idea because personally I can’t access it (don’t have the rights) :grinning:

Is there an error message in the console?

1 Like

The link has been modified so that you can view the material.

  1. How to write the end point?

  2. How to make a post form?

I wonder.

Hi,

With post method you need three things:

  1. URL - what service you are using
  2. Headers - metadata and authentications
  3. Payload - data you are sending

Headers seem ok. Your current URL is the root of the server. In document they mention endpoint for measurements /api/v2/measurements. So URL for it would be https://getefento.com/api/v2/measurements.
In headers and in manual payload format it JSON. On page 11 there is given structure for measurement and an example. I you are not familiar with JSON google it. Java has libraries to make working with JSON easier.

2 Likes