Is there any way to send json as the payload for the an httpPost method in a SIL script? I've tried setting the header to:
string [] headers = "Content-Type|application/json";
And the payload to:
string [] payload = {"text", "This is a test"};
but I get a 500 response from the server.
Community moderators have prevented the ability to post new answers.
Hi Chris,
You can send json via httpPost if it is manually created, see the script below:
string url = "https://slack.com/api/chat.postMessage"; string [] headers = "Content-Type|application/json"; string json = "{\"name\": \"value\"}"; //The following JSON example defines an employees object, with an array of 3 employee records: string jsonArr = "{\"employees\": [" + "{\"firstName\": \"John\", \"lastName\": \"Doe\"}" + "{\"firstName\": \"Anna\", \"lastName\": \"Smith\"}" + "{\"firstName\": \"Peter\", \"lastName\": \"Jones\"}" + "]}"; string [] payload = {"myJson", json}; return httpPost(url, headers, payload);
Best regards,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You shall add to headers
Authorization|Basic X==
X a string of base64-encoded username:password
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not working, i have the folowing error :
IO exception performing HTTP POST: peer not authenticated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Walid,
Since the 4.1.0 version of Power Scripts (May 2018) we have added a bunch of new routines that should make it a lot easier for you to deal with HTTP requests from SIL.
For the description of the new routines and some usage examples, please consult the docs at the following address:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chris,
It seems like at this moment you cannot do this. We will create an internal ticket for that and we will update this ticket when the feature is production ready so you can get notified.
Regards,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.