Skip to main content
Best answer

How to manage optional fields in API call

  • January 28, 2024
  • 2 replies
  • 47 views

Hello,

I try to connect the Gravity Form from my wordpress website to one API of the government.

I don’t know how to manage the fields that are optional in the API.

 

"NomUsage" for example. It is a name. If user write in this field on my Gravity Form, no problem, this is written in the API call : "NomUsage" : "Nameofuser"

 

But if the user writes nothing in Gravity Form, this is written in the API call : "NomUsage" : "" and the API return an error because it expects the line to be removed.

 

Could you please help me ?

 

Thanks a lot !

 

Best answer by Troy Tessalone

Hi @Glomaro 

You may need to add custom Code logic to configure the API data JSON structure so it is dynamic.

Code: https://zapier.com/apps/code/help

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • Answer
  • January 28, 2024

Hi @Glomaro 

You may need to add custom Code logic to configure the API data JSON structure so it is dynamic.

Code: https://zapier.com/apps/code/help


  • Author
  • Beginner
  • January 28, 2024

Hi Troy,

 

Thanks a lot for your answer, I’ll try that.