Invalid OPENID on sending Push Messages (Customer Services Messages)

When trying to send push messages via the Customer Services Messages API you might encounter an Invalid OPENID error even though you are passing a valid OPENID.

JSON structure

WeChat is very particular about its JSON structure. Even though you pass your JSON in the same structure as what is described in the documentation it is very specific.

Solution

Remove all single quotes as delimeters and rather use double quotes.

Works: {“touser”:”oLC8gs4QtR2kwMG2EMygtHN7Qh_Q”,”msgtype”:”text”,”text”:{“content”:”test”}}

Does not work: {‘touser’:’oLC8gs4QtR2kwMG2EMygtHN7Qh_Q’,’msgtype’:’text’,’text’:{‘content’:”test”}}

Other problems

Also remove all extra spaces and newline characters

Works: {“touser”:”oLC8gs4QtR2kwMG2EMygtHN7Qh_Q”,”msgtype”:”text”,”text”:{“content”:”test”}}

Does not work:

{“touser”:”oLC8gs4QtR2kwMG2EMygtHN7Qh_Q”,

“msgtype”:”text”,

“text”:

{“content”:”test”}

}