Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
and if you pass a context:
it will json dump for you, and place inside the data
:see: https://developers.hubspot.com/docs/methods/forms/submit_form
"""
if context:
data["hs_context"] = json.dumps(context)
subpath = "{}/{}".format(portal_id, form_guid)
opts = {"content_type": "application/x-www-form-urlencoded"}
options.update(opts)
response = self._call(
subpath, method="POST", data=urlencode(data), raw=True, **options
)
if response.status in [
FormSubmissionClient.ResponseCode.SUCCESS,
FormSubmissionClient.ResponseCode.SUCCESS_AND_REDIRECT,
]:
return response
if response.status == FormSubmissionClient.ResponseCode.NOT_FOUND:
raise HubspotNotFound(response, None)
if response.status == FormSubmissionClient.ResponseCode.ERROR:
raise HubspotServerError(response, None)
# shouldn't ever get here, but raise anyways
raise HubspotServerError(response, None)
if context:
data["hs_context"] = json.dumps(context)
subpath = "{}/{}".format(portal_id, form_guid)
opts = {"content_type": "application/x-www-form-urlencoded"}
options.update(opts)
response = self._call(
subpath, method="POST", data=urlencode(data), raw=True, **options
)
if response.status in [
FormSubmissionClient.ResponseCode.SUCCESS,
FormSubmissionClient.ResponseCode.SUCCESS_AND_REDIRECT,
]:
return response
if response.status == FormSubmissionClient.ResponseCode.NOT_FOUND:
raise HubspotNotFound(response, None)
if response.status == FormSubmissionClient.ResponseCode.ERROR:
raise HubspotServerError(response, None)
# shouldn't ever get here, but raise anyways
raise HubspotServerError(response, None)
:see: https://developers.hubspot.com/docs/methods/forms/submit_form
"""
if context:
data["hs_context"] = json.dumps(context)
subpath = "{}/{}".format(portal_id, form_guid)
opts = {"content_type": "application/x-www-form-urlencoded"}
options.update(opts)
response = self._call(
subpath, method="POST", data=urlencode(data), raw=True, **options
)
if response.status in [
FormSubmissionClient.ResponseCode.SUCCESS,
FormSubmissionClient.ResponseCode.SUCCESS_AND_REDIRECT,
]:
return response
if response.status == FormSubmissionClient.ResponseCode.NOT_FOUND:
raise HubspotNotFound(response, None)
if response.status == FormSubmissionClient.ResponseCode.ERROR:
raise HubspotServerError(response, None)
# shouldn't ever get here, but raise anyways
raise HubspotServerError(response, None)
this will urlencode the data automatically
and if you pass a context:
it will json dump for you, and place inside the data
:see: https://developers.hubspot.com/docs/methods/forms/submit_form
"""
if context:
data["hs_context"] = json.dumps(context)
subpath = "{}/{}".format(portal_id, form_guid)
opts = {"content_type": "application/x-www-form-urlencoded"}
options.update(opts)
response = self._call(
subpath, method="POST", data=urlencode(data), raw=True, **options
)
if response.status in [
FormSubmissionClient.ResponseCode.SUCCESS,
FormSubmissionClient.ResponseCode.SUCCESS_AND_REDIRECT,
]:
return response
if response.status == FormSubmissionClient.ResponseCode.NOT_FOUND:
raise HubspotNotFound(response, None)
if response.status == FormSubmissionClient.ResponseCode.ERROR:
raise HubspotServerError(response, None)
# shouldn't ever get here, but raise anyways
raise HubspotServerError(response, None)