What I would like to do is post a multipart form to a messageboard. After submitting the form, the messageboard does not contain the new submitted post. Below is the PowerShell code, verbose output, and a sample network capture of a successful post via Internet Explorer 9. I have successfully logged in and continue to use a session.
I think the ‘-ContentType’ and/or ‘-Body’ parameters are incorrect.
# Fill out form fields # All other fields in network capture have default values # ($forms.Fields) TypeName: System.Collections.Generic.Dictionary $forms.Fields._19_cmd = 'add' $forms.Fields._19_subject = 'Subject Test' $forms.Fields._19_editor = 'Body Test' $forms.Fields._19_body = 'Body Test' $forms.Fields._19_workflowAction = '1' # Submit Form $Type = 'multipart/form-data; boundary=---------------------------7df14832203f6' $submitform = Invoke-WebRequest -Uri $forms.action -Body $forms.Fields -Method Post -WebSession $session1 -ContentType $Type -Verbose
Verbose Output
VERBOSE: POST
http://ipaddress/edit_message with 3608-byte payload
VERBOSE: received 61701-byte response of content type text/html;charset=UTF-8
Network Capture
REQUEST HEADERS
Request: POST /web/action%3D%252Fmessage_boards%252Fedit_message HTTP/1.1
Accept: text/html, application/xhtml+xml, /
Referer: /web/action=%2Fmessage_boards%2Fedit_message
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Content-Type: multipart/form-data; boundary=---------------------------7df14832203f6
Accept-Encoding: gzip, deflate
Connection: Keep-Alive Cache-Control: no-cache
REQUEST HEADERS
REQUEST BODY
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_formDate”
1450725819960
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_cmd”
add
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_redirect”
http://ipaddress/view&p_p_col_id=column-2&p_p_col_count=1
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_messageId”
0
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_mbCategoryId”
0
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_threadId”
0
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_workflowAction”
1
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_subject”
Subject Test
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_editor”
Body Test
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_body”
Body Test
-----------------------------7df14832203f6
Content-Disposition: form-data; name=“_19_msgFile1”; filename=“”
Content-Type: application/octet-stream
-----------------------------7df14832203f6