Отправить JSON в запросе PUT - PullRequest
0 голосов
/ 11 июня 2019

Следующие проходы (взяты из https://gatling.io/docs/2.3/http/http_request/, удалены .toJSON, поскольку он не существует), но не добавляют запись в API REST:

class TestREST extends Simulation {
  val httpProtocol = http
    .baseUrl("http://127.0.0.1:5000") // Here is the root for all relative URLs

  val scn = scenario("UploadMany") // A scenario is a chain of requests and pauses
    .exec(http("request_1")
      .put("/")
      .body(StringBody("""{
            "text":"lalala", "title": "hello world", "date": "12346"}"""))
      .check(status.is(200))
    )

  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))

}

Как добавитьДанные JSON в .put запрос с Gatling?

1 Ответ

1 голос
/ 11 июня 2019

Я удалил .asJSON из примера на https://gatling.io/docs/2.3/http/http_request/,, так как это не удалось.Этот метод был переименован в (с большой буквы) .asJson в 3.1, поэтому следующее изменение исправляет его:

  .body(StringBody("""{
        "text":"lalala", "title": "hello world", "date": "12346"}""")).asJson
...