Cucumber for Appian: Post http post web api request

Hello everyone, I am currently trying to post a http post request using Cucumber for Appian to the Appian system itself using the cheat sheet made available by Appian. But I am facing errors and I am unsure what Im supposed to put in the 'BODY' parameter. Please see below:


Cucumber scripts cheat sheet: 

# Call a web API with a body and return result as a string. User defined by username must have permission to access the web API:
Given I post web api "WEB_API_ENDPOINT" with body "BODY" with username "USERNAME"

Cucumber script in .feature file: 
Given I post web api "">appian-example.com/.../createNewProduct" with body "" with username "example_appian"

Error: And I post web api "">appian-example.com/.../createNewProduct" with body "" with username "example_appian" # CucumberBaseFixture.postWebApiWithBodyWithUsername(String,String,String)
com.appiancorp.ps.automatedtest.exception.GenericTestException: message:<<An error has occurred: Call Web API>>
at com.appiancorp.ps.automatedtest.exception.ExceptionBuilder.build(ExceptionBuilder.java:71)
at com.appiancorp.ps.automatedtest.common.AppianWebApi.callWebApi(AppianWebApi.java:51)
at com.appiancorp.ps.automatedtest.fixture.BaseFixture.postWebApiWithBodyWithUsername(BaseFixture.java:672)
at com.appiancorp.ps.cucumber.fixtures.CucumberBaseFixture.postWebApiWithBodyWithUsername(CucumberBaseFixture.java:106)
at ✽.I post web api "">appian-example.com/.../createNewProduct" with body "" with username "example_appian"(src/test/resources/ApplicationExample.feature:75)

  Discussion posts and replies are publicly visible

Parents
  • Hello Rabiah,

    A post operation requires a body, which means the parameters you are sending are in the body (create a new client, update the client, delete the client with id #)

    If you webapi Justo query information is more likely to be a get operation. On which you don’t have to pass parameters.

    From your example you are trying to create a new product so you need to pass all the data of the product you are trying to create I guess you are using Json?

    Maybe something like

    {productName:“product1”}

    Hope this helps

    Jose

  • Hi Jose, I was indeed trying to do a POST api request and I managed to understand how the post API cheat sheet was talking about. for the WEB_API_ENDPOINT script (Given I post web api "WEB_API_ENDPOINT" with body "BODY" with username "USERNAME"), it ws referring to just the endpoint instead of the full URL of the web api. eg. ">appian-example.com/.../createNewProduct", the endpoint Cucumber for Appian is looking for is actually just "createNewProduct"

     thank you for the answer and the next step of my work is to send a json request and have 2 questions regarding it.

    1) what if i have a very long json request to be processed in Appian? is there a way i can store my request in a .json file and call it in cucumber for appian script?

    2) How do I read the response from making the web api call in cucumber?

  • 0
    Certified Associate Developer
    in reply to Rabiah Khairy

    Hi Rabiah were you able to complete a successful cucumber test with testing an appian api? I am having trouble with it and see no documentation.

  • hi laurela, in the end i didnt make use of their body as it seems to be unrealistic to throw a big json body request into it. I created my own custom cucumber scripts that would take in my own personal request in my .json file. So its smth like "Given I send my request", and in the backend, its a list of codes calling the web api and forming my body request. Its easier to read and manage

Reply Children
No Data