Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use a parameter from a POST response in the body of a different POST request? #908

Open
chkp-meitalka opened this issue Aug 7, 2024 · 0 comments

Comments

@chkp-meitalka
Copy link

chkp-meitalka commented Aug 7, 2024

Description

Hello,

I have a service with an endpoint "/show-x", which accepts a POST request and returns a JSON response with one key - "task-id". This is because the endpoint works asynchronously, and the idea is to use "task-id" as the input of another endpoint called "/show-task", which also accepts a POST request, then the response would be the result of "/show-x" assuming that it was done.

I tried to mark this relationship using the following annotation:

      {
         "producer_resource_name": "task-id",
         "producer_method": "POST",
         "producer_endpoint": "/show-x",
         "consumer_param": "task-id",
         "consumer_method": "POST",
         "consumer_endpoint": "/show-task"
       }

It seems to work in that I see this in grammar.py:

req_collection = requests.RequestCollection([])
# Endpoint: /show-task, method: Post
request = requests.Request([
    primitives.restler_static_string("POST "),
    primitives.restler_basepath("/gaia_api/v1.8"),
    primitives.restler_static_string("/"),
    primitives.restler_static_string("show-task"),
    primitives.restler_static_string(" HTTP/1.1\r\n"),
    primitives.restler_static_string("Accept: application/json\r\n"),
    primitives.restler_static_string("Host: 172.29.70.75\r\n"),
    primitives.restler_static_string("Content-Type: "),
    primitives.restler_static_string("application/json"),
    primitives.restler_static_string("\r\n"),
    primitives.restler_refreshable_authentication_token("authentication_token_tag"),
    primitives.restler_static_string("\r\n"),
    primitives.restler_static_string("{"),
    primitives.restler_static_string("""
    "task-id":"""),
    **primitives.restler_static_string(_show_x_post_task_id.reader(), quoted=False),**
    primitives.restler_static_string("}"),
    primitives.restler_static_string("\r\n"),

],
requestId="/show-task"
)

However, when I try to run test, fuzz-lean and fuzz the show-task request never gets rendered, even if there were "/show-x" requests that returned status 200 OK and a json response with a task-id. Is it because both requests are POST requests? Is there a log file that should let me know what the issue is?

Could it also be because the response for "show-task" in the open api spec is defined as "OneOf" two different schemas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant