I can't find an example to post form-data to login and get authorization code using jOkHttpUtils2. Thanks for help!
Post address: http://192.168.100.2/EHCommon/admin/user/login
Headers:
Content-Type: application/x-www-form-urlencoded
Body form-data:
http_api_version: 4.16.1
username: admin
password: xxxxxx
This is the Postman catpure that can get right response:
This is the java code converted by Postman, but I don't know how to convert MultipartBody part to B4J:
Post address: http://192.168.100.2/EHCommon/admin/user/login
Headers:
Content-Type: application/x-www-form-urlencoded
Body form-data:
http_api_version: 4.16.1
username: admin
password: xxxxxx
This is the Postman catpure that can get right response:
This is the java code converted by Postman, but I don't know how to convert MultipartBody part to B4J:
Java:
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("http_api_version","4.16.1")
.addFormDataPart("username","admin")
.addFormDataPart("password","dc047c30ebf9dac462908aadad719dce")
.build();
Request request = new Request.Builder()
.url("http://192.168.100.2/EHCommon/admin/user/login")
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();