HTTP Requests Error

Hi all
I’m trying to make a post request in my android sketch but I’m getting issues.

This is my code:

import http.requests.*;

void setup () {
        
    PostRequest post = new PostRequest("https:// < my REST API url >");
        
    post.addHeader("Content-Type", "application/json");  
    post.addData("{\"key1\":33,\"key2\":44,\"key3\":55}");
    post.send();
    
    println("Response: " + post.getContent());  
}

I’m using the latest version of the HTTP Requests for Processing library.

When I’m running the code in Java Mode it works fine and my API it’s correctly called with the json as payload of the request.

But when I try to run the code in Android Mode, building the sketch on my phone, I’m having this issue:

FATAL EXCEPTION: Animation Thread
java.lang.IncompatibleClassChangeError: Class 'org.apache.http.conn.ssl.SSLSocketFactory' 
does not implement interface 'org.apache.http.conn.scheme.SchemeSocketFactory' 
in call to 'java.net.Socket org.apache.http.conn.scheme.SchemeSocketFactory.createSocket(org.apache.http.params.HttpParams)'

I don’t understand what’s wrong, I guess it has something to do with Android since it’s working fine in Java Mode. Is Processing for Android not intended to make http requests?

I’m stuck with this for a while, I hope someone can help me. Thanks! :blush: