Skip to content

How to encode some data, which we need to use in consecutive requests #675

@warademilind

Description

@warademilind

Please find below attached json requests.
here,

${$.POST_QUESTIONS.response.body.id}  is #37:29 every-time its different.
How we can encode like %2337%3A1529
 we need to send that encoded data in next URL. how to do it in Zerocode.
ex.  String input ="#37:29";        
String encoded = URLEncoder.encode(input,"UTF-8");         
System.out.println(encoded);
// Output: %2337%3A1529
{
	"scenarioName": "POST_QUESTION",
	"ignoreStepFailures": true,
	"steps": [
		{
			"name": "POST_QUESTIONS",
			"url": "/questions",
			"operation": "POST",
			"request": {
				"headers": {
					"Authorization": "Bearer ${bearertoken}"
				},
				"body": {
					"question": "zerocode"
				}
			},
			"assertions": {
				"status": 201,
				"body": {
					"id": "${$.POST_QUESTIONS.response.body.id}"
				}
			}
		},
		{
			"name": "GET_QUESTIONS",
			"url": "/questions",
			"operation": "GET",
			"request": {
				"headers": {
					"Authorization": "Bearer ${bearertoken}"
				}
			},
			"assertions": {
				"status": 200
			}
		},
		{
			"name": "UPDATE_QUESTION",
			"url": "/questions/${$.POST_QUESTIONS.response.body.id}",
			"operation": "PUT",
			"request": {
				"headers": {
					"Authorization": "Bearer ${bearertoken}"
				},
				"body": {
					"id": "#43:118",
					"question": "Zerocode Question 123"
				}
			},
			"assertions": {
				"status": 200
			}
		},
		{
			"name": "DELETE_QUESTION",
			"url": "/questions/${$.POST_QUESTIONS.response.body.id}",
			"operation": "DELETE",
			"request": {
				"headers": {
					"Authorization": "Bearer ${beareretoken}"
				}
			},
			"assertions": {
				"status": 204
			}
		}
	]
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions