# @Form

Outra opção é criar um objeto que representa a estrutura de um formulário, anotado com `@Form`:

```java
@Form
class MyForm {

  @Field
  String name;

  @Field("customer_age")
  int age;
}

public interface MyApi {

  /* em requisições com o content-type application/x-www-form-urlencoded,
  objetos anotados com @Form serão automaticamente serializados */

  @Path("/customers") @Post
  @FormURLEncoded
  Customer createCustomer(@BodyParameter MyForm parameters);

}
```

Objetos anotados com `@Form` também podem ser utilizados em requisições do tipo `GET`, usando o serializador `FormObjectParameterSerializer`. O objeto será deserializado em uma `query string`.

```java
import com.github.ljtfreitas.restify.http.client.message.converter.form.FormObjectParameterSerializer;

public interface MyApi {

  @Path("/customers") @Get
  Customer findCustomerByParameters(@QueryParameters(serializer = FormObjectParameterSerializer.class) MyForm myForm);

}

public static void main(String[] args) {

  MyApi myApi = new RestifyProxyBuilder()
      .target(GitHub.class)
          .build();

  MyForm myForm = new FormParameters();
  myForm.name = "Tiago de Freitas Lima";
  myForm.age = 31;

  // name=Tiago+de+Freitas+Lima&customer_age=31
  Customer customer = myApi.findCustomerByParameters(myForm);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ljtfreitas.gitbook.io/java-restify/tipos-de-conteudo/list/url-encoded/form.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
