OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"personData\":{\"externalId\":\"1\",\"firstName\":\"Jane\",\"lastName\":\"Smith\",\"address\":\"67 Farringdon Road\",\"city\":\"London\",\"country\":\"United Kingdom\",\"gender\":\"FEMALE\",\"birthDate\":\"1966-01-15\",\"middleName\":\"Janie\",\"profilePicture\":\"http://profile.com\",\"tags\":[\"VIP Customers\",\"New Customers\"],\"customAttributes\":{\"Contract Expiry\":\"2018-06-01\",\"Company\":\"Acme\"},\"contactInformation\":{\"phone\":[{\"number\":\"41793026727\"},{\"number\":\"41793026728\"}],\"email\":[{\"address\":\"jane@acme.com\"},{\"address\":\"janesmith@acme.com\"}]}},\"flowVariables\":{\"orderDate\":\"2021-09-01\",\"orderDetails\":\"Extended Weight, Discount\",\"orderNumber\":1234567}}");
Request request = new Request.Builder()
.url("https://{baseUrl}/communication/1/flows/10159347/participants?phone&email=janewilliams@example.com&externalId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab&pushRegistrationId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab")
.method("POST", body)
.addHeader("Authorization", "{authorization}")
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.build();
Response response = client.newCall(request).execute();
2
3
4
5
6
7
8
9
10
11
12
13
{
"personData": {
"externalId": "1",
"firstName": "Jane",
"lastName": "Smith",
"address": "67 Farringdon Road",
"city": "London",
"country": "United Kingdom",
"gender": "FEMALE",
"birthDate": "1966-01-15",
"middleName": "Janie",
"profilePicture": "http://profile.com",
"tags": [
"VIP Customers",
"New Customers"
],
"customAttributes": {
"Contract Expiry": "2018-06-01",
"Company": "Acme"
},
"contactInformation": {
"phone": [
{
"number": "41793026727"
},
{
"number": "41793026728"
}
],
"email": [
{
"address": "jane@acme.com"
},
{
"address": "janesmith@acme.com"
}
]
}
},
"flowVariables": {
"orderDate": "2021-09-01",
"orderDetails": "Extended Weight, Discount",
"orderNumber": 1234567
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var client = new RestClient("https://{baseUrl}/communication/1/flows/10159347/participants?phone&email=janewilliams@example.com&externalId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab&pushRegistrationId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "{authorization}");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
var body = @"{""personData"":{""externalId"":""1"",""firstName"":""Jane"",""lastName"":""Smith"",""address"":""67 Farringdon Road"",""city"":""London"",""country"":""United Kingdom"",""gender"":""FEMALE"",""birthDate"":""1966-01-15"",""middleName"":""Janie"",""profilePicture"":""http://profile.com"",""tags"":[""VIP Customers"",""New Customers""],""customAttributes"":{""Contract Expiry"":""2018-06-01"",""Company"":""Acme""},""contactInformation"":{""phone"":[{""number"":""41793026727""},{""number"":""41793026728""}],""email"":[{""address"":""jane@acme.com""},{""address"":""janesmith@acme.com""}]}},""flowVariables"":{""orderDate"":""2021-09-01"",""orderDetails"":""Extended Weight, Discount"",""orderNumber"":1234567}}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
2
3
4
5
6
7
8
9
10
11
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
<code>url := "https://%7BbaseUrl%7D/communication/1/flows/10159347/participants?phone&email=janewilliams@example.com&externalId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab&pushRegistrationId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab" method := "POST" payload := strings.NewReader(`{"personData":{"externalId":"1","firstName":"Jane","lastName":"Smith","address":"67 Farringdon Road","city":"London","country":"United Kingdom","gender":"FEMALE","birthDate":"1966-01-15","middleName":"Janie","profilePicture":"http://profile.com","tags":["VIP Customers","New Customers"],"customAttributes":{"Contract Expiry":"2018-06-01","Company":"Acme"},"contactInformation":{"phone":[{"number":"41793026727"},{"number":"41793026728"}],"email":[{"address":"jane@acme.com"},{"address":"janesmith@acme.com"}]}},"flowVariables":{"orderDate":"2021-09-01","orderDetails":"Extended Weight, Discount","orderNumber":1234567}}`) client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) return } req.Header.Add("Authorization", "{authorization}") req.Header.Add("Content-Type", "application/json") req.Header.Add("Accept", "application/json") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body))</code>
}
2
3
4
5
6
7
8
9
10
11
import http.client
import json
conn = http.client.HTTPSConnection("{baseUrl}")
payload = json.dumps({
"personData": {
"externalId": "1",
"firstName": "Jane",
"lastName": "Smith",
"address": "67 Farringdon Road",
"city": "London",
"country": "United Kingdom",
"gender": "FEMALE",
"birthDate": "1966-01-15",
"middleName": "Janie",
"profilePicture": "http://profile.com",
"tags": [
"VIP Customers",
"New Customers"
],
"customAttributes": {
"Contract Expiry": "2018-06-01",
"Company": "Acme"
},
"contactInformation": {
"phone": [
{
"number": "41793026727"
},
{
"number": "41793026728"
}
],
"email": [
{
"address": "jane@acme.com"
},
{
"address": "janesmith@acme.com"
}
]
}
},
"flowVariables": {
"orderDate": "2021-09-01",
"orderDetails": "Extended Weight, Discount",
"orderNumber": 1234567
}
})
headers = {
'Authorization': '{authorization}',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
conn.request("POST", "/communication/1/flows/10159347/participants?phone=null&email=janewilliams@example.com&externalId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab&pushRegistrationId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "uri"
require "json"
require "net/http"
url = URI("https://{baseUrl}/communication/1/flows/10159347/participants?phone&email=janewilliams@example.com&externalId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab&pushRegistrationId=8edb24b5-0319-48cd-a1d9-1e8bc5d577ab")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "{authorization}"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request.body = JSON.dump({
"personData": {
"externalId": "1",
"firstName": "Jane",
"lastName": "Smith",
"address": "67 Farringdon Road",
"city": "London",
"country": "United Kingdom",
"gender": "FEMALE",
"birthDate": "1966-01-15",
"middleName": "Janie",
"profilePicture": "http://profile.com",
"tags": [
"VIP Customers",
"New Customers"
],
"customAttributes": {
"Contract Expiry": "2018-06-01",
"Company": "Acme"
},
"contactInformation": {
"phone": [
{
"number": "41793026727"
},
{
"number": "41793026728"
}
],
"email": [
{
"address": "jane@acme.com"
},
{
"address": "janesmith@acme.com"
}
]
}
},
"flowVariables": {
"orderDate": "2021-09-01",
"orderDetails": "Extended Weight, Discount",
"orderNumber": 1234567
}
})
response = https.request(request)
puts response.read_body
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58