Search API v3 using Javajcript

Hi,

I want to get the contacts that is created base on the time filter.

Using Postman as a test, I was able to receive the expected response.

But upon creation using javascript, I receive this kind of error response.

Code:

var headers = new Array();
 	headers['accept'] = '*/*';
 	headers['Content-Type'] = 'application/json';
 	var url = "https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=hapikey"
 	var body = {
 		 "filterGroups":[
 		 {
 		 "filters": [
 		 {
 		 "propertyName": "createdate",
 		 "operator": "GT",
 		 "value": "1602123448000"
 		 }
 		 ] 
 		 }
 		 ]
 		 }
 	var response = https.post({
			url:url,
			headers:headers,
			body:body
		});

Response:

{
"status":"error",
"message":"Invalid input JSON on line 1, column 14: Unrecognized token 'filterGroups': was expecting 'null', 'true', 'false' or NaN",
"correlationId":"54873d32-5fb2-42ac-81e9-ff1ba7a69905"
}

I can’t figure out on which part has problem.

Can someone help/teach me to correct this?

hi @jm_tangile , are you still struggling with this?

@lynton , @malcolm1 -- Do either of you have suggestions here?

Thanks!

Looking at var “response” you say URL:URL, BODY:BODY. That could be messing things up. If you named your variables differently the problem might go away. Another potential problem is that you are going to transmit a string and BODY is an array. Make it a string.

I’m already good with my issue. The problem was the body should be in string. Thanks guys!