Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Unable to POST to MemberImportForm programatically


Reply


409 Views

Avatar
JeffMcClintock

Community Member, 1 Post

8 November 2011 at 12:24pm

Edited: 08/11/2011 12:27pm

Hi All,
I'm trying to write a program to import new Members via the Security Admin 'Import' page. I'm using the program Fiddler to diagnose the communication. Logging in and navigating to the page seems to work fine, it's posting the form that don't.
Here's the dump. First: normal browser posting the form succesfully. 2nd: My C# code posting the form using a HttpWebRequest. My code fails to add the new memeber to the Silverstripe database. Any suggestions appreciated. Jeff.

--Me operating a web browser=====================================================

POST http://www.synthedit.com/admin/security/MemberImportForm HTTP/1.1
Accept: text/html, text/html, */*
Referer: http://www.synthedit.com/admin/security/memberimport
Accept-Language: en-NZ
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Content-Type: multipart/form-data; boundary=---------------------------7db2e42c60870
Accept-Encoding: gzip, deflate
Host: www.synthedit.com
Content-Length: 498
Connection: Keep-Alive
Pragma: no-cache
Cookie: __utma=148077877.1849251437.1260424688.1320695175.1320707633.522; __utmz=148077877.1319790845.509.75.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=depends.exe%20site%3Asynthedit.com; __utmx=148077877.; __utmxx=148077877.; __utmb=148077877.1.10.1320707633; __utmc=148077877; PastMember=1; PHPSESSID=dda3e6a592af856c73c1f72d647877ec

-----------------------------7db2e42c60870
Content-Disposition: form-data; name="CsvFile"; filename="ImportMe.csv"
Content-Type: application/vnd.ms-excel

Email,Password,FirstName,Surname
keenan@xxx.com,xxx,Keenan,Windel
-----------------------------7db2e42c60870
Content-Disposition: form-data; name="MAX_FILE_SIZE"

-----------------------------7db2e42c60870
Content-Disposition: form-data; name="action_doImport"

Import
-----------------------------7db2e42c60870--

--My code emulating a web browser=============================================

POST http://www.synthedit.com/admin/security/MemberImportForm HTTP/1.1
Content-Type: multipart/form-data; boundary=-----------------------------8ce6c28353f2c3d
Referer: http://www.synthedit.com/admin/security/memberimport
Host: www.synthedit.com
Cookie: PHPSESSID=b3149781439881ab6a69dccff0377460; PastMember=1
Cache-Control: no-store,no-cache
Pragma: no-cache
Content-Length: 506
Expect: 100-continue

-----------------------------8ce6c28353f2c3d
Content-Disposition: form-data; name="CsvFile"; filename="ImportMe.csv"
Content-Type: application/vnd.ms-excel

Email,Password,FirstName,Surname
moose@moose.com,Moose3964,Moosie,Moose
-----------------------------8ce6c28353f2c3d
Content-Disposition: form-data; name="MAX_FILE_SIZE"

-----------------------------8ce6c28353f2c3d
Content-Disposition: form-data; name="action_doImport"

Import
-----------------------------8ce6c28353f2c3d--