Python create Contact with umlauts

Hey Guys!

i currently create contacts over the API, it also working flawless with normal ones.

But when a customer have umaluts in their name i get problems.

	def createContact(self,props):
		output = "{\"properties\": ["
		for prop in props:
			output = output + prop.getJSON() + ","
		output = output[:-1] + "]}"
		headers = {"Content-Type":"application/json"}
		r = requests.post(self.AUTH_URL + "/contacts/v1/contact/?hapikey="+API_KEY, data = output, headers = headers )
		return r.json()

This code works flawless with normal contacts, but with umlauts i get this error.

#closed

when i add directly in the request function “.encode” everything works, when i want to encode just the variable then it’s not working…weird

fix:

	def createContact(self,props):
		output = "{\"properties\": ["
		for prop in props:
			output = output + prop.getJSON() + ","
		output = output[:-1] + "]}"
		headers = {"Content-Type":"application/json"}
		r = requests.post(self.AUTH_URL + "/contacts/v1/contact/?hapikey="+API_KEY, data = output.encode('utf-8'), headers = headers )
		return r.json()

Thanks for sharing your solution, @akaiser!