java.lang.IllegalArgumentException: Don't know how to encode

300 views
Skip to first unread message

pruthvi reddy

unread,
Jul 29, 2019, 1:06:47 PM7/29/19
to REST assured
my code:

package com.**.testapi.blitz;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.testng.Assert;
import org.testng.annotations.Test;

import com.**.main.Configuration;
import com.**.pojo.TC09_BLITZ_POJO_EnableManageraccess;
import com.**.testng.BaseTest;
import com.**.testng.CommonUtils;

import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;


public class TC09_BLITZ_POST_EnableManagerAccess extends BaseTest{
Configuration config = new Configuration();
@Test
public void enableManagerAccess() throws Exception
{
ArrayList<TC09_BLITZ_POJO_EnableManageraccess> jsonbody = new ArrayList<TC09_BLITZ_POJO_EnableManageraccess>();
TC09_BLITZ_POJO_EnableManageraccess json_data = new TC09_BLITZ_POJO_EnableManageraccess(974934,66385,"true");
jsonbody.add(json_data);
String pretty_json = CommonUtils.prettyJsonRequest(json_data);
//System.out.println(pretty_json);
RestAssured.baseURI = config.getQA_BASE_URL();

Response resp = RestAssured
.given()
.log().all()
.when()
.header("Content-Type","application json;charset = UTF-8")
//.accept(ContentType.TEXT)
.body(pretty_json)
.post("/api/v1/projects/projectmembers")
.then()
.assertThat()
.statusCode(200)
//.and()
//.contentType(ContentType.JSON)
.extract()
.response();
//String resp_body = resp.getBody().asString();
//CommonUtils.printPrettyJsonResponse(resp_body);  
}

}






i get this error:

FAILED: 
java.lang.IllegalArgumentException: Don't know how to encode {
  "clientId" : 974934,
  "ProjectId" : 66385,
  "sendEmail" : "true"
} as a byte stream.

Anurima Chandra

unread,
Jul 30, 2019, 7:03:56 AM7/30/19
to REST assured
Hi purthvi,
Thic code might help you

public static String workbookname()
{
String workbookName="Auto-Color";
String x 
         = Base64.encodeBase64String(workbookName.getBytes()); 
return x ;
Reply all
Reply to author
Forward
0 new messages