Zoho Rest 发票 API Return 400 错误,Java HttpClient
Zoho Rest Invoice API Return 400 Error, Java HttpClient
我想将 Zoho Invoice API 集成到我的 Spring 应用程序中。我已经成功整合了 AuthToken
部分。现在我正在使用创建联系人 API。但是APIreturns报错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();
}
我使用 sam 方法获取可用的访问令牌,但在使用它创建联系人时出现 returns 错误。谁能告诉我如何解决这个问题?
`API-URL`: https://invoice.zoho.com/api/v3/contacts
json String
: "{\"contact_name\":\"Jay Panjwanai\",\"company_name\":\"Ozone\",\"billing_address\":{\ "attention\":\"Jay \",\"address\":\"${地址}\",\"city\":\"INDORE\",\"country\": \"India\",\"phone\":9xxxxxxxxx},\"shipping_address\":{\"attention\":\"Jay\",\"address\":\"${地址}\",\"city\":\"INDORE\",\"country\":\"India\",\"phone\":9xxxxxxxxx}}"
提前致谢!
好吧,在与他们的支持团队讨论后,我得到了答案。只需删除以下行:
con.setRequestProperty("Content-Type", "multipart/form-data");
这造成了问题。
此致
我想将 Zoho Invoice API 集成到我的 Spring 应用程序中。我已经成功整合了 AuthToken
部分。现在我正在使用创建联系人 API。但是APIreturns报错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();
}
我使用 sam 方法获取可用的访问令牌,但在使用它创建联系人时出现 returns 错误。谁能告诉我如何解决这个问题?
`API-URL`: https://invoice.zoho.com/api/v3/contacts
json String
: "{\"contact_name\":\"Jay Panjwanai\",\"company_name\":\"Ozone\",\"billing_address\":{\ "attention\":\"Jay \",\"address\":\"${地址}\",\"city\":\"INDORE\",\"country\": \"India\",\"phone\":9xxxxxxxxx},\"shipping_address\":{\"attention\":\"Jay\",\"address\":\"${地址}\",\"city\":\"INDORE\",\"country\":\"India\",\"phone\":9xxxxxxxxx}}"
提前致谢!
好吧,在与他们的支持团队讨论后,我得到了答案。只需删除以下行:
con.setRequestProperty("Content-Type", "multipart/form-data");
这造成了问题。
此致