on 12-18-2015 11:00 AM
I am facing error when i try to read the value from url of sender REST adapter
I followed this blog.
http://host:port/RESTAdapter/Hub/Employee/<employeenumber>
here this part employeenumber is dynamic.
When I run the interface, I am not getting the correct rsponse. If I hard code in the mapping the input value, I get the correct response so something wrong with my code.
this is the code i used
public String getASMA(String namespace, String attribute, Container container) throws StreamTransformationException{
Map<String, Object> all = container.getInputHeader().getAll();
DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);
String value = dynConf.get(key);
return value;
}
in mapping I did like this
two constants mapped to udf at input side and the output mapped to the value that i need to fill
first constant is employeenumber
second constant is http:// sap.com/xi/XI/System/REST
what is the wrong? I am entering two constants
Hello Midhun,
Please have a look into this blog post - it contains details about configuration of REST sender communication channel and mapping, that fulfils your requirement.
Few checks to be verified:
1. In REST sender channel: on "REST resources tab", did you specify URL pattern and mapping from custom attribute to PI dynamic attribute correctly? Variables in URL pattern shall be surrounded by curly brackets. For example, in a URL you provided above, URL custom pattern shall be /Hub/Employee/{employeenumber}, assuming employeenumber is a variable that you then map to a dynamic attribute (based on your description, having identical name).
2. Can you ensure a message gets corresponding custom dynamic attribute created and populated? For a processed message, please check its message attributes in Message Monitor > Message Versions (available by clicking a button "Open Message"). On the tab "Message Attributes", can you see an attribute "employeenumber" and a valid value assigned to it?
Regards,
Vadim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's an RFC at the receiver side, so I am not able to check where to find the hits. RFC is not visible in MONI
I did this way
Channel Selection Tab
Specify Endpoint was ticked
Then in REST Resources tab
URL custom pattern is {employeenumnber}
Under that, XI Dynamic Attribute
dynamic Attribute REST id id
Value Source URL Pattern Element
Pattern Element employeenumber
Employeenumber value is then mapped to EMPNR in the RFC
I have given two inputs, to RFC, one is xi/sytem and the other is id
I am now getting output
irrespective of what i give i am getting output of one value 10001
The response always gives that even if i give 10002 in the url
I changed it to how you said.
Left the Channel selection tab blank
Now I am getting this eror
Parsed attribute "id": "100021"
Processing HTTP call: GET http://xxxxxxx:51000//Hub/Employee//100027
Even though I am sending the employee number 100027, it's parsing 100021 and fetching the details of the employee 21 from the ECC system.
Irrespective of whatever value I send in the url, I am getting the details of 10021
I used 100014, 100015 etc
Midhun,
In an error message, I see two slash symbols in a called URL (before "100027"). Can you please check that and ensure you don't have typos when calling URL on a client side.
For REST sender configuration, please try to switch from "REST ID (id)" to "Custom Attribute" in order to me able to map custom attribute name ("employeenumber" in your case). When using custom attribute option, you will be able to map arbitrary name of an attribute you used in URL, with PI dynamic attribute.
Regards,
Vadim
Hi Vadim
It worked and many thanks.
My mistake was this. I was using CustomAttribute under the XI Dynamic Attributes. I gave CustomAttributeName and PatternElement ad "EmployeeNumber"
In the mapping, I used dynamic configuration. GetASMA. I gave two constants as inputs. The first was http://sap.com/xi/XI/System/REST and the second was "id". I saw in message attributes of the payload that the value passed is held in EmployeeNumber
I gave the attribute input for the udf as EmployeeNumber, and now it's working
Thanks a ton
Under XI Dynamic attributes, if you are using the Dynamic attribute as REST id (id), then we need to give the input for the dynamic configuration udf in message mapping shoulod be as the following
1) http://sap.com/xi/XI/System/REST
2) id
then also it will work
Hi Glen,
Yes, thank you for pointing this out - the location of the blog post that I referred to, got changed. Here is a current link to that blog post: https://blogs.sap.com/2014/12/18/pi-rest-adapter-using-dynamic-attributes/.
Regards,
Vadim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Midhun,
So ur keeping emp No dyanmic and also u wish to get the URL in the mapping?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.