Hi,
I have created a!writeToDataStore in webAPI which is writing to DB when I test through API,to invoke this API I created an integration of Method POST and URL accepting ri! as parameters.
I am unable to write to DB when I test through integration.Can someone please help where I am going wrong.
Later I want to use this integration in my interface.
Thanks in advance!
Discussion posts and replies are publicly visible
You can use a!writeToDataStore() directly in your Appian interface.
In the onSuccess and onFailure parameters of a!writeToDatastore you can return an HTTP response using the a!httpResponse() function. I recommend using this to help you view useful information when testing in the API designer.
Hi Danny Verb
Thanks for the reply I tried that only first,
but this is what I get in response,not sure what I am missing.
a!localVariables( local!value: a!writeToDataStoreEntity( dataStoreEntity: cons!DS, valueToStore: ri!variable, 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" } ) ) ), local!value )
You can't test Smart Services in the expression rule editor, instead, try running that code directly in the Web API designer. Also, since you don't need any local variables there's not need to put your a!writeToDataStoreEntity() in a local variable
Danny Verb
Did that too
But then how to I use WEB API in my interface ,if the answer is via integration, I did try that but unable to connect.
I can share details for integration too.
WEB API works fine,but I am unable to fetch the response in integration or directly in interface.
When you say interface are you referring to an Appian Interface? You shouldn't use Web APIs in your interface since you can call smart services directly. Simply place them into the saveInto field of a dynamicLink() or buttonWidget()
To test this, make an interface with a simple a!linkField(links: {a!dynamicLink( saveInto: {})}) and try to write to the database using this link.
I already have a link for starting the process, I wanted to utilise same to add data to DB or maybe prior using local!variables or integration.
But looks like will have to create a new PM to write data to DB and then invoke my usual PM
Thanks for quick response!
Yes, you can create a constant pointing to your process model and then use a!startProcess() to kick off the process model from an interface
Danny Verb Thats already in place will use that.
Thanks!