Mobile app - Submit form

I am working on a mobile app & want to connect a Marketing > Form to our CRM > Contact database. I think I have to use the API to send a Post request to the server.

Can’t get the form to post. What methods are implemented when embedding forms into mobile apps?

I think this is the endpoint I need to hit - Documented here
https://api.hsforms.com/submissions/v3/integration/secure/submit/\[ClientID]/\[FormID]

However, no matter what I do, it keeps kicking me back a 401 auth error (below). Do I need to obtain a bearer token before submitting form or is there another way?

{
    “status”: “error”,
    “message”: “Any of the listed authentication credentials are missing”,
    “correlationId”: “6e5e…”,
    “engagement”: {
        “oauth-token”: “oauth-token not engaged. OAuth access token not found in request header.”,
        “service-to-service”: “service-to-service not engaged. Metadata for service-to-service request not found.”,
        “hapikey”: “hapikey not engaged. hapikey is not present in query params.”,
        “app-cookie”: “app-cookie not engaged. App cookie is not present on the request.”,
        “internal-cookie”: “internal-auth not engaged. Service using internal auth must be deployed on an internal load balancer.”
    }
}

Hi @NeptuneGlobal,

Thank you for reaching out to the Community!

Let’s consult with a few experts for guidance.

Hello @Jnix284, @JuanGomez0818, @GRajput - Do you have any advice for @NeptuneGlobal regarding the error they are encountering?

Thanks,

Diana

Thanks for the tag @DianaGomez, this is a little outside of my experience with APIs, hopefully one of the others can help!

I heard back from support. They indicate that I have to use one of these two methods.

After reading I think the private app method will work. It is hard to say, since they don’t seem to give a clear indication of what the private app is.

Hey, @NeptuneGlobal :waving_hand: I’m happy to help. You are on the right path.

Here are some steps to take, plus an example of what including your Private App might look like:

  • Create a Private App — navigate to Settings > Integrations > Private Apps > Create a Private App

  • Give your Private App the necessary scopes. You can find this info in the Forms API dev doc

  • In this case, you’ll need to add the Forms scope

An example request using a Private App for auth and cURL (I used the example JSON from the dev doc and added the auth header example):

curl -X POST \
 'https://api.hubapi.com/submissions/v3/integration/submit/YOUR_PORTAL_ID/YOUR_FORM_GUID' \
 -H 'Content-Type: application/json' \
 -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
 -d '{
 "submittedAt": "1517927174000",
 "fields": [
 {
 "objectTypeId": "0-1",
 "name": "email",
 "value": "example@example.com"
 },
 {
 "objectTypeId": "0-1",
 "name": "firstname",
 "value": "Jeff"
 }
 ],
 "context": {
 "hutk":"hutk",
 "pageUri": "www.example.com/page",
 "pageName": "Example page"
 },
 "legalConsentOptions": {
 "consent": {
 "consentToProcess": true,
 "text": "I agree to allow Example Company to store and process my personal data.",
 "communications": [
 {
 "value": true,
 "subscriptionTypeId": 999,
 "text": "I agree to receive marketing communications from Example Company."
 }
 ]
 }
 }
}'

Lastly, if you use Postman, you can get it to generate various code examples, which include the formatting for your auth header, from the </> (code) option

I hope this helps get you moving forward! Talk soon — Jaycee