Cant work with umlaute ( ä,ö,ü) and Invoice API

olthom
Contributor
Contributor

Hello!

 

I am trying to set up a Java Projekt in which i create and send invoices. 

 

Unfortunately it seems, that the APi has problems handling umlaute ( Ä, Ü, Ö) in my requests

This is the response i get if the name contains an umlaut. ( i used Öliver as an example)

"name":"INVALID_REQUEST",
"message":"Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id":"3195c3b15b67e",
"details":[
{
"field":"invoicer/name/given_name",
"location":"body",
"description":"Invalid UTF-8 middle byte 0x6c at line:1, column:338"


This is the part of the Code that creates the invoice

URL invoiceUrl = new URL(invoiceEndpoint);
        HttpURLConnection invoiceConn = (HttpURLConnection) invoiceUrl.openConnection();
        invoiceConn.setRequestMethod("POST");
        invoiceConn.setRequestProperty("Authorization", "Bearer " + accessToken);
        invoiceConn.setRequestProperty("Content-Type", "application/json");
        invoiceConn.setRequestProperty("Prefer", "return=representation");
        invoiceConn.setRequestProperty("charset", "utf-8");

        invoiceConn.setDoOutput(true);
        OutputStreamWriter invoiceWriter = new OutputStreamWriter(invoiceConn.getOutputStream());
        invoiceWriter.write(invoice.toString());
        invoiceWriter.flush();
        invoiceWriter.close();


Thank you for your help

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.