APIs & Integrations

pradheep
Member

Getting a hubspot deal property by a API call throw 400 Error.

I am trying to load a deal property by calling a hubspot deal property API.

 

But while fetching the details of a property (Using Java Code - Apache HTTP Client call) the API throw 400 error code.

 

The below are details

Fetching the hubspot property :https://api.hubapi.com/properties/v1/deals/properties/named/plan_type/?hapikey=abc123

 

Response:

Printing the response from hubspot:<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 400 Bad Request</title>
</head>
<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /properties/v2/deal/properties/named/plan_type/. Reason:
<pre> Bad Request</pre></p>
</body>
</html>

 

Kindly help here.

 

I tried to set headers like this

headerMap.put("content-type", "application/json");
headerMap.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0");

0 Upvotes
2 Replies 2
pradheep
Member

Getting a hubspot deal property by a API call throw 400 Error.

But this same URL when i hit in browser it returns the Json response properly.

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Getting a hubspot deal property by a API call throw 400 Error.

Hey @pradheep,

 

Digging into this, I saw this GET apache HttpClient example: https://mkyong.com/webservices/jax-rs/restful-java-client-with-apache-httpclient/ and I noticed that they are requesting a GET request like this:

 

DefaultHttpClient httpClient = new DefaultHttpClient();
		HttpGet getRequest = new HttpGet(
			"http://localhost:8080/RESTfulExample/json/product/get");
		getRequest.addHeader("accept", "application/json");

This looks a little different from the method that you're using. Could you try the above and see if it works?