Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

x-www-form-urlencoded support #20

Open
Filter94 opened this issue Oct 23, 2017 · 3 comments
Open

x-www-form-urlencoded support #20

Filter94 opened this issue Oct 23, 2017 · 3 comments
Assignees
Labels

Comments

@Filter94
Copy link
Contributor

Filter94 commented Oct 23, 2017

I tried to bound my x-www-form-urlencoded parameters with corresponding annotation (@ApiRequestParam) but it fails to send the request by casting Map to String.
Right here: https://github.com/sbtqa/api-factory/blob/5665d2f272e2f88d66d29e6c4977b38b0427e8f9/src/main/java/ru/sbtqa/tag/apifactory/rest/RestRawImpl.java#L83
I don't understand how it supposed to work with any kind of params tbh.

@Filter94
Copy link
Contributor Author

Here is LoginEntity:

package ru.sbt.qa.ekpit.api.test.entries;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.sbtqa.tag.apifactory.ApiEntry;
import ru.sbtqa.tag.apifactory.annotation.AddBracket;
import ru.sbtqa.tag.apifactory.annotation.ApiAction;
import ru.sbtqa.tag.apifactory.annotation.ApiRequestHeader;
import ru.sbtqa.tag.apifactory.annotation.ApiRequestParam;
import ru.sbtqa.tag.qautils.properties.Props;

import java.net.InetAddress;
import java.net.UnknownHostException;

@ApiAction(method = "post", path = "pkmslogin.form",
        title = "авторизация")
public class LoginEntry extends ApiEntry {
private static final Logger log = LoggerFactory.getLogger(LoginEntry.class);

@ApiRequestParam(title = "domain")
    private String domain = "";

    @ApiRequestParam(title = "username")
    private String username = Props.get("auth.username");

    @ApiRequestParam(title = "password")
    private String password = Props.get("auth.password");

    @AddBracket(value = "login-form-type")
    private final String loginFormType = "pwd";

    @ApiRequestHeader(header = "Content-Type")
    private final String contentType = "application/x-www-form-urlencoded";

    @ApiRequestHeader(header = "Upgrade-Insecure-Requests")
    private final String upgradeInsecureRequests = "1";

    @ApiRequestHeader(header = "User-Agent")
    private final String userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36";

    @ApiRequestHeader(header = "Accept")
    private final String accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
}

@kosteman
Copy link
Contributor

kosteman commented Oct 24, 2017

Please try to use RestFormImpl.
To use it you need to add next line to your @ before step def
ApiFactory.getApiFactory().setRest(RestFormImpl.class);

@clicman
Copy link
Contributor

clicman commented Oct 24, 2017

@0I0u3uk add this section into docs

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

No branches or pull requests

4 participants