APIs & Integrations

jm_tangile
Participant

Search API v3 using Javajcript

SOLVE

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?

0 Upvotes
1 Accepted solution
malcolm1
Solution
Member | Gold Partner
Member | Gold Partner

Search API v3 using Javajcript

SOLVE

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. 

 

 

View solution in original post

3 Replies 3
jm_tangile
Participant

Search API v3 using Javajcript

SOLVE

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

malcolm1
Solution
Member | Gold Partner
Member | Gold Partner

Search API v3 using Javajcript

SOLVE

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. 

 

 

dennisedson
Community Manager
Community Manager

Search API v3 using Javajcript

SOLVE

hi @jm_tangile , are you still struggling with this?

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

 

Thanks!


loop Loop Marketing is a new four-stage approach that combines AI efficiency and human authenticity to drive growth.
Learn More