Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Call post api from interface

Certified Associate Developer

Hi, 

i've a portal with some users fileds. When i compile the fields on click button i want to save this fields in my appian db using post api (i want to test the API). I wrote this code for the portal interface:

=a!localVariables(
local!nome,
local!cognome,
local!dataNascita,
local!indirizzoResidenza,
local!codiceFiscale,
{
a!textField(
label: "Nome",
value: local!nome,
saveInto: local!nome
),
a!textField(
label: "Cognome",
value: local!cognome,
saveInto: local!cognome
),
a!textField(
label: "Data di nascita",
value: local!dataNascita,
saveInto: local!dataNascita
),
a!textField(
label: "Indirizzo di residenza",
value: local!indirizzoResidenza,
saveInto: local!indirizzoResidenza
),
a!textField(
label: "Codice fiscale",
value: local!codiceFiscale,
saveInto: local!codiceFiscale
),
a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Invia dati",
saveInto: {
}
)
}
)
}
)

I also created a post api:

a!localVariables(
local!value: cast(
'type!{urn:com:appian:types:AHUTENTE}AH_UTENTE',
a!fromJson(http!request.body)
),
a!writeToDataStoreEntity(
dataStoreEntity: cons!AH_UTENTE_DSE_POINTER,
valueToStore: local!value,
onSuccess: a!httpResponse(
statusCode: 200,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
fv!storedValues
)
),
onError: a!httpResponse(
statusCode: 500,
headers: {
a!httpHeader(name: "Content-Type", value: "application/json")
},
body: a!toJson(
{
error: "There was an error writing to the data store"
}
)
)
)
)

Now I was wondering, how do I call the API to write to the db within the interface and pass the parameters? Do I need anything else? Sorry but I'm not very practical.

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Associate Developer
    in reply to Harshit Bumb (Appyzie)

    Ok done but when click on test i've this message "

    error-result-label

    Authentication is required

    error-result-guidance

    This request requires Basic authentication, but no credentials were provided HTTP/1.1 401 Next Steps

    • Provide credentials (username and password) and retry the request

    so i put basic auth -> insert my user and pass and i've this "

    error-result-label

    Something went wrong

    error-result-guidance

    Failed to connect to mptq.appian.community/.../add-new-user Next Steps

    • Check the error message for more information
    • Try the request again
    • If the problem persists, ask an administrator to investigate the problem

    "

    Why??

Children