Hubspot Connector
Documentation
Version: 5
Documentation

EndPoint Generic Request


Name

generic_request

Description

This is generic endpoint. Use this endpoint when some actions are not implemented by connector. Just enter partial URL (Required), Body, Method, Header etc. Most parameters are optional except URL.

Parameters

Parameter Label Required Options Description
Url Url YES API URL goes here. You can enter full URL or Partial URL relative to Base URL. If it is full URL then domain name must be part of ServiceURL or part of TrustedDomains
Body Body NO Request Body content goes here
IsMultiPart IsMultiPart NO Set this option if you want to upload file(s) using either raw file data (i.e., POST raw file data) or send data using the multi-part encoding method (i.e. Content-Type: multipart/form-data). A multi-part request allows you to mix key/value pairs and upload files in the same request. On the other hand, raw upload allows only a single file to be uploaded (without any key/value data). ==== Raw Upload (Content-Type: application/octet-stream) ===== To upload a single file in raw mode, check this option and specify the full file path starting with the @ sign in the Body (e.g. @c:\data\myfile.zip) ==== Form-Data / Multipart Upload (Content-Type: multipart/form-data) ===== To treat your request data as multi-part fields, you must specify key/value pairs separated by new lines in the RequestData field (i.e., Body). Each key/value pair should be entered on a new line, and key/value are separated using an equal sign (=). Leading and trailing spaces are ignored, and blank lines are also ignored. If a field value contains any special character(s), use escape sequences (e.g., for NewLine: \r\n, for Tab: \t, for at (@): @). When the value of any field starts with the at sign (@), it is automatically treated as a file you want to upload. By default, the file content type is determined based on the file extension; however, you can supply a content type manually for any field using this format: [YourFileFieldName.Content-Type=some-content-type]. By default, file upload fields always include Content-Type in the request (non-file fields do not have Content-Type by default unless you supply it manually). If, for some reason, you don't want to use the Content-Type header in your request, then supply a blank Content-Type to exclude this header altogether (e.g., SomeFieldName.Content-Type=). In the example below, we have supplied Content-Type for file2 and SomeField1. All other fields are using the default content type. See the example below of uploading multiple files along with additional fields. If some API requires you to pass Content-Type: multipart/form-data rather than multipart/form-data, then manually set Request Header => Content-Type: multipart/mixed (it must start with multipart/ or it will be ignored). file1=@c:\data\Myfile1.txt file2=@c:\data\Myfile2.json file2.Content-Type=application/json SomeField1=aaaaaaa SomeField1.Content-Type=text/plain SomeField2=12345 SomeFieldWithNewLineAndTab=This is line1\r\nThis is line2\r\nThis is \ttab \ttab \ttab SomeFieldStartingWithAtSign=\@MyTwitterHandle
Filter Filter NO
Option Value
No filter
Example1 $.store.books[*]
Example2 (Sections Under Books) $.store.books[*].sections[*]
Example3 (Equals) $.store.books[?(@author=='sam')]
Example4 (Equals - Any Section) $..[?(@author=='sam')]
Example5 (Not Equals - Any Section) $..[?(@author!='sam')]
Example6 (Number less than) $.store.books[?(@.price<10)] Example7 (Regular Expression - Contains Pattern)=$.store.books[?(@author=~ /sam|bob/ )]
Example8 (Regular Expression - Does Not Contain Pattern) $.store.books[?(@author=~ /^((?!sam|bob).)*$/ )]
Example9 (Regular Expression - Exact Pattern Match) $.store.books[?(@author=~ /^sam|bob$/ )]
Example10 (Regular Expression - Starts With) $.store.books[?(@author=~ /^sam/ )]
Example11 (Regular Expression - Ends With) $.store.books[?(@author=~ /sam$/ )]
Example12 (Between) $.store.employees[?( @.hiredate>'2015-01-01' && @.hiredate<'2015-01-04' )]
Enter filter to extract array from response. Example: $.rows[*] --OR-- $.customers[*].orders[*]. Check your response document and find out hierarchy you like to extract
Headers Headers NO Headers for Request. To enter multiple headers use double pipe or new line after each {header-name}:{value} pair

Output Columns

Label Data Type (SSIS) Data Type (SQL) Length Raw Description
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime.

Input Columns

Label Data Type (SSIS) Data Type (SQL) Length Raw Description
There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime.

Examples

SSIS

Use Hubspot Connector in API Source component to read data or in API Destination component to read/write data:

Generic Request using API Source

Hubspot
Generic Request
SSIS API Source - Read from table or endpoint

Generic Request using API Destination

Hubspot
Generic Request
SSIS API Destination - Access table or endpoint

ODBC application

Use these SQL queries in your ODBC application data source:

Generic Request (Company Search API Example)

This example shows how to invoke generic request when connector file doesnt have specific EndPoint / Table you like to query. This example invokes search endpoint but you can call any valid API endpoint GET/POST etc with this method

SELECT *
FROM generic_request
WITH(
     Url='crm/v3/objects/companies/search'
    ,Filter='$.results[*]'
    ,RequestContentTypeCode='ApplicationJson'
    ,RequestMethod='POST'
    ,RequestData='{
        "filters": [ {"propertyName": "hs_lastmodifieddate", "operator": "GT", "value": "<<yearstart-1y||unix_timestamp_ms,FUN_TO_DATE>>" } ],
        "properties": ["address","city","state"]  
        }'
)

Upload File (Generic Request Example)

This example shows how to upload a file using generic request. You might have to add file-manager-permission to your OAuth App else you might get message=This oauth-token (CJT87I6) does not have proper permissions! (requires any of [file-manager-access]). For more information please refer to this link https://developers.hubspot.com/docs/api/files/files

SELECT *
FROM generic_request
WITH(
	  Url='filemanager/api/v3/files/upload'
	, RequestMethod='POST'
	, Filter ='$.objects[*]'
	, Body='file=@c:\temp\dump.png
folderPath=/
fileName=my_dump.png
options={"access": "PRIVATE", "overwrite": true}'
	, IsMultiPart='True'
	, Meta='id:long; name:string; title:string; url: string; type:string; size:long; friendly_url:string; meta.allows_anonymous_access:string; meta.indexable:bool'
)

SQL Server

Use these SQL queries in SQL Server after you create a data source in Data Gateway:

Generic Request (Company Search API Example)

This example shows how to invoke generic request when connector file doesnt have specific EndPoint / Table you like to query. This example invokes search endpoint but you can call any valid API endpoint GET/POST etc with this method

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM generic_request
WITH(
     Url=''crm/v3/objects/companies/search''
    ,Filter=''$.results[*]''
    ,RequestContentTypeCode=''ApplicationJson''
    ,RequestMethod=''POST''
    ,RequestData=''{
        "filters": [ {"propertyName": "hs_lastmodifieddate", "operator": "GT", "value": "<<yearstart-1y||unix_timestamp_ms,FUN_TO_DATE>>" } ],
        "properties": ["address","city","state"]  
        }''
)';

EXEC (@MyQuery) AT [LS_TO_HUBSPOT_IN_GATEWAY];

Upload File (Generic Request Example)

This example shows how to upload a file using generic request. You might have to add file-manager-permission to your OAuth App else you might get message=This oauth-token (CJT87I6) does not have proper permissions! (requires any of [file-manager-access]). For more information please refer to this link https://developers.hubspot.com/docs/api/files/files

DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT *
FROM generic_request
WITH(
	  Url=''filemanager/api/v3/files/upload''
	, RequestMethod=''POST''
	, Filter =''$.objects[*]''
	, Body=''file=@c:\temp\dump.png
folderPath=/
fileName=my_dump.png
options={"access": "PRIVATE", "overwrite": true}''
	, IsMultiPart=''True''
	, Meta=''id:long; name:string; title:string; url: string; type:string; size:long; friendly_url:string; meta.allows_anonymous_access:string; meta.indexable:bool''
)';

EXEC (@MyQuery) AT [LS_TO_HUBSPOT_IN_GATEWAY];