Last active
August 29, 2015 14:06
-
-
Save ArionHardison/78089bf2c16f72ed456d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void CreateSignup(string fName, string lName, string state, string phone, string zip, string userId, string email) | |
{ | |
try | |
{ | |
string NB_ID = string.Empty; | |
using (WebClient NB_API_Client = new WebClient()) | |
{ | |
NB_API_Client.Headers["Content-type"] = "application/json"; | |
NB_API_Client.Headers["Accept"] = "application/json"; | |
NB_API_Base = 'arion.nationbuilder.com' | |
accessToken = nil | |
PersonNew person = new PersonNew(); | |
person.first_name = fName; | |
person.last_name = lName; | |
person.email = email; | |
person.phone = phone; | |
RegisteredAddress regAddr = new RegisteredAddress(); | |
regAddr.state = state; | |
regAddr.zip = zip; | |
person.registered_address = regAddr; | |
person.is_volunteer = true; | |
CreateObject crtpeople = new CreateObject(); | |
List<PersonNew> persondata = new List<PersonNew>(); | |
persondata.Add(person); | |
crtpeople.person = persondata; | |
string reqPersons = string.Empty; | |
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer(); | |
reqPersons = jsonSerializer.Serialize(crtpeople); | |
string res1 = reqPersons.Replace("[", ""); | |
string finalres = res1.Replace("]", ""); | |
MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(finalres)); | |
by2 = NB_API_Client.UploadData(NB_BASE + "/api/v1/people" + "?access_token=" + accessToken, "POST", memoryStream.ToArray()); | |
string resData = string.Empty; | |
resData = Encoding.ASCII.GetString(by2); | |
RootObject personReturnObject = new RootObject(); | |
personReturnObject = jsonSerializer.Deserialize<RootObject>(resData); | |
NB_ID = Convert.ToString(personReturnObject.person.id); | |
} | |
} | |
catch (Exception e) | |
{ | |
MailSend("Error in method CreatePeople for NB_ID : " + NB_ID, e.Message.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment