I wrote an auto test for filling out and submitting a form, did all this through userInterface, using selenium. Today I learned that you can do the same thing only through a POST request.

There is a form. In the form of the field "Name", "Text", "Save" button

How to perform actions on filling in the fields and clicking the Save button, post a request?

Request URL:http://localhost:8080/admin/content/contents/create Request Method:POST Status Code:302 Found Remote Address:127.0.0.1 Referrer Policy:no-referrer-when-downgrade Response Headers view source Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Connection:keep-alive Content-Length:0 Content-Type:text/html Date:Mon, 29 May 2017 07:27:53 GMT Expires:Thu, 19 Nov 1981 08:52:00 GMT Location:http://localhost:8080/admin/content/contents/index Pragma:no-cache Server:nginx/1.8.0 Request Headers view source 

Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, image / webp, / ; q = 0.8

Accept-Encoding: gzip, deflate

Accept-Language: ru-RU, ru; q = 0.8, en-US; q = 0.6, en; q = 0.4

 Cache-Control:max-age=0 Connection:keep-alive Content-Length:289 Content-Type:application/x-www-form-urlencoded Cookie:user_lang=ru; YII_CSRF_TOKEN=d4242e009637469aaa9049e10027b6950cea195d; user_basket=734966a2f6efbd4131880f02848ae281307d629e; PHPSESSID=mo934sblvv33dn3kvua6kpjop6; backurl=http%3A//localhost:8080/admin/content/contents/create Host:localhost:8080 Origin:http://localhost:8080 Referer:http://localhost:8080/admin/content/contents/create Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Form Data view source view URL encoded YII_CSRF_TOKEN:d4242e009637469aaa9049e10027b6950cea195d ContentsLang[lang]:ru ContentsLang[text]:<p>test Article poas name</p> ContentsLang[name]:test Article post area[textareackeditor]:<p>test Article poas name</p> area[textareablock]: 
  • Install Postman and Postman Interceptor. Interceptor'om catch request, Postman generate code for C # - tym32167
  • If you want to write C # code that will send a post-request, then look at the WebRequest class and documentation on it. It's pretty simple there - The Impatient

0