scalagatlingscala-gatling

How to convert the said curl to equivalent scala Gatling code?


Please help in how to convert below curl to equivalent scala Gatling code?

            curl --location --request POST 'https://test.salesforce.com/services/oauth2/token' \
            --header 'Content-Type: application/x-www-form-urlencoded' \
            --header 'Cookie: BrowserId=DbIfsfsf' \
            --data-urlencode 'username=webapi@abc.com.uat1' \
            --data-urlencode 'client_id=xxx' \
            --data-urlencode 'client_secret=xxxx' \
            --data-urlencode 'grant_type=password' \
            --data-urlencode 'password=xxxx'

Solution

  • Here there are all answers on your question https://docs.gatling.io/reference/script/protocols/http/request/


    val myRequest = http("my request")
        .post("https://test.salesforce.com/services/oauth2/token")
        .header(HttpHeaderNames.ContentType, HttpHeaderValues.ApplicationFormUrlEncoded)
        .header("Cookie", "BrowserId=DbIfsfsf")
        .formParam("username", "webapi@abc.com.uat1")
        .formParam("client_id", "xxx")
        .formParam("client_secret", "xxxx")
        .formParam("grant_type", "password")
        .formParam("password", "xxxx")