Zoho Rest发票API返回400错误,Java HttpClient
我想在我的Spring应用程序中集成Zoho发票API。我已成功集成了Zoho Rest发票API返回400错误,Java HttpClient,java,spring-boot,invoice,zoho,Java,Spring Boot,Invoice,Zoho,我想在我的Spring应用程序中集成Zoho发票API。我已成功集成了AuthToken部分。现在我正在使用createcontactapi。但API返回一个错误400 我正在使用以下代码: public String processZohoRequest(String apiUrl,Map<String, String> params,String method, String auth) throws UnsupportedEncodingException, IOExcepti
AuthToken
部分。现在我正在使用createcontactapi。但API返回一个错误400
我正在使用以下代码:
public String processZohoRequest(String apiUrl,Map<String, String> params,String method, String auth) throws UnsupportedEncodingException, IOException {
URL url = new URL(apiUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod(method);
if(!AppUtility.isEmpty(auth)) {
con.setRequestProperty("Authorization", auth);
con.setRequestProperty("Content-Type", "multipart/form-data");
con.setRequestProperty("X-com-zoho-invoice-organizationid", testZohoOrgId);
}
if(!AppUtility.isEmpty(params)) {
con.setDoOutput(true);
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.writeBytes(ParameterStringBuilder.getParamsString(params));
out.flush();
out.close();
}
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
con.disconnect();
return content.toString();
}
json字符串
:“{”联系人姓名“:\”Jay Panjwanai\“,”公司名称“:”Ozone\“,”账单地址“:{”注意“:”Jay\“,”地址“:“$”,”城市“:”INDORE\“,”国家“:”印度“,”电话“:9XXXXXXXXXXXXX\”,”航运地址“:{”注意“:”Jay\“,”地址“,”地址“:”INDORE\”,”国家“,”印度“,”国家“,”地址“,”INDORE\”电话\“:9xxxxxxxxx}}”
提前谢谢 与他们的支持团队讨论后,我得到了答案。只需删除以下行:
con.setRequestProperty("Content-Type", "multipart/form-data");
这造成了一个问题
问候
con.setRequestProperty("Content-Type", "multipart/form-data");