12-09-2016 10:23 AM
Hi I am creating a site here, but this sometimes works and sometimes not working.
try {
HttpClient client = new HttpClient();
String loginData = "username=admin&password=admin";
PostMethod loginPost = new PostMethod(
"http://127.0.0.1:8090/share/page/dologin");
loginPost.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
loginPost.setRequestEntity(new StringRequestEntity(loginData,
"text/plain", "UTF-8"));
System.out.println("dologin script status: "
+ client.executeMethod(loginPost));
GetMethod authenticationGet = new GetMethod(
"http://127.0.0.1:8090/share/service/modules/authenticated?a=user");
System.out.println("User is authenticated script status : "
+ client.executeMethod(authenticationGet));
PostMethod createSitePost = new PostMethod(
"http://127.0.0.1:8090/share/service/modules/create-site");
String shortName = "TestSiteFromCodeONeTwo";
JSONObject siteObject = new JSONObject();
siteObject.put("shortName", shortName);
siteObject.put("description", shortName);
siteObject.put("title", shortName);
siteObject.put("Visiblity", "Public");
siteObject.put("sitePreset", "site-dashboard");
createSitePost.setRequestEntity(new StringRequestEntity(siteObject
.toString(), "application/json", "UTF-8"));
createSitePost.setRequestHeader("Accept", "application/json");
// createSitePost.setRequestHeader("Content-Type", "application/json");
int status = client.executeMethod(createSitePost);
System.out.println("create a site script status :: " + status);
getting error
create a site script status :: 400
12-09-2016 11:02 AM
There should be more information in the response indicating why it failed. A 400 response code suggests that there was something wrong with your request - what is the response message? Is it possible that you're trying to create a site using a shortName attribute that has already been used?
12-09-2016 11:05 AM
create a site script status :: 400{
"status" :
{
"code" : 400,
"name" : "Bad Request",
"description" : "Request sent by the client was syntactically incorrect."
},
"message" : "error.unableToCreate",
"exception" : "",
"callstack" :
[
],
"server" : "Spring WebScripts - v6.5.0 schema 1,000",
"time" : "Dec 9, 2016 9:34:15 PM"
}
12-09-2016 11:32 AM
What are the actual values that you're submitting when you make that request? Is it possible that you're submitting invalid characters, etc? For example there are a number of characters that can't be used for the shortName attribute.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.