Question
How to pass custom HTTP header in Connect-REST
Hi All,
How can we pass custom HTTP header in Connect-REST request ? could you please help us in this regards issue ?
Example : i need to pass custom header CustomID in request header below
"request_headers": { "singularityheader": "appId=24317*ctrlguid=1597251625*acctguid=497dba83-2de2-46ca-8106-b56e4214096c*ts=1597345099796*btid=1591793*guid=7f70a3e8-ef85-4255-9351-14c0d51eb0a7*exitguid=15*unresolvedexitid=35938520*cidfrom=386299*etypeorder=HTTP*esubtype=HTTP*cidto=A26897", "user-agent": "Apache-HttpClient/4.5.2 (Java/1.8.0_151)", "accept-encoding": "gzip,deflate", "host": "pizza-proxy-xyz-onprem.apps.ent-ocp-np1-har.antmdc.internal.das", "x-forwarded-host": "pizza-proxy-xyz-onprem.apps.ent-ocp-np1-har.antmdc.internal.das", "x-forwarded-port": "443", "x-forwarded-proto": "https", "forwarded": "for=30.118.252.62;host=pizza-proxy-xyz-onprem.apps.ent-ocp-np1-har.antmdc.internal.das;proto=https;proto-version=", "x-forwarded-for": "30.118.252.62"
CustomID:1234 },
we do have another thread for SOAP (https://collaborate.pega.com/question/how-pass-http-header-connect-soap) but i'm looking for REST
***Edited by Moderator Marissa to update General to Product***
added this part of code in Connect-REST Invoke step 5 , but experiencing NULL pointer exception.
com.pega.apache.http.impl.client.DefaultHttpClient client = new com.pega.apache.http.impl.client.DefaultHttpClient(); com.pega.apache.http.client.methods.HttpPost post = new com.pega.apache.http.client.methods.HttpPost(); try { java.util.List list = new java.util.ArrayList(); list.add(new com.pega.apache.http.message.BasicNameValuePair("userId", "123456789")); if(methodName=="POST"){ post.setEntity(new com.pega.apache.http.client.entity.UrlEncodedFormEntity(list));
com.pega.apache.http.HttpResponse response = client.execute(post); } if(methodName=="GET"){
com.pega.apache.http.client.methods.HttpGet httpget = new com.pega.apache.http.client.methods.HttpGet(com.pega.apache.http.client.utils.URLEncodedUtils.format(list, "utf-8")); com.pega.apache.http.HttpResponse response = client.execute(httpget); } } catch (java.io.IOException e) { // e.printStackTrace(); String msg = "Failed while " + ", " + e.toString(); oLog.error(msg, e); }