How to send encrypted message using API?

The JSON response I got show origin message in plain text if I use "messageToEncrypt:true",

    "attachment": {
        "version.Message": 1,
        "messageIsText": true,
        "message": "test",
        "encryptedMessage": {
            "data": "724a76811fd543a28d87cb10c9b4b397c036acffe8ebc271759875b7691bcb33810f18e60fbb9a63f24fb80410642c63",
            "nonce": "a92506bb2bb3b108902e4209c109c6374f1b910ef9796f0232595344cbdc1f19",
            "isText": true,
            "isCompressed": true
        },
        "version.ArbitraryMessage": 0,
        "version.EncryptedMessage": 1
    },

The encrypted message send by wallet didn't show the plain text. Thanks

The question should be:
How to send an encrypted message using API without showing the message in plain text in attachment?

If it's not a problem for you to send the original message to the server, i.e. you problem is only that the server returns the original message after you've send it to it, then you can call the encryptTo API first and then provide the result as encryptedMessageData and encryptedMessageNonce parameters and not use the message and messageToEncrypt parameters. You won't get the original message in response, e.g.

    "attachment": {
        "encryptedMessage": {
            "data": "84a0e755146148050d6efd8f2593df346fa9b9485eb2b68f4efe048f53100280647d76dcea18ae6d8ef497b1889e363c",
            "nonce": "e62d503a4d8c24b73841e0a27f649d844b3c82db8e4bbb0b4363fe6f0d588da2",
            "isText": true,
            "isCompressed": true
        },
        "version.OrdinaryPayment": 0,
        "version.EncryptedMessage": 1
    }

If your problem is also that the original message is sent to the server, then you need to calculate locally the data and nonce and again provide them as encryptedMessageData and encryptedMessageNonce

Thanks!