on 11-04-2013 7:57 AM
Hi Colleagues,
I redefined one method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY in the following Gateway Service Class, and use the following URL to test activity create operation via t-code /IWFND/GW_CLIENT(Gateway Client) in Gateway Service system, e.g. PGX system. But get one error message 'CSRF token validation failed' as shown below, please tell me how to solve this issue?
And there is no problem to do Query operation, e.g., search for activities using the following first URL. But unable to do Create operation using the following second URL, if I set breakpoint in the CREATE_ENTITY method, system cannot jump to there, instead jump to the GET_ENTITYSET method. Could you please tell me how to solve this issue?
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList
Kind Regards
Andie
Hi Andie, please try using the search option before posting queries, this one is quite a common "issue". You'll get answers more quickly
For example: http://scn.sap.com/thread/3424154
Regards
Ron.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ron,
I did the same as you said, and also I test it using RESTClient in Firefox browser as below. But get error messages as screen shot shown below.
If I use the following URL, will get error message as below.
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList('0000303019')
If I use the following URL, will get error message as below.
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList
Kind Regards
Andie
Hi Ron,
I define one entity set named 'ActivityList' in the following class, which used for query and create operation.
And redefine method CREATE_ENTITY as below. Please check whether my coding is correct or not? When I set breakpoint in this method, and call the following URL, system cannot jump to this method. Instead, jump to method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET.
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList
Kind Regards
Andie
Hi Ron,
Here is my XML for this case. Where can I find XML checker or do I need to download this tool from website?
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://pgxmain.wdf.sap.corp:1080/sap/opu/odata/sap/ZS_ESCALATIONS/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id>http://pgxmain.wdf.sap.corp:1080/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList('0000203012')</id>
<title type="text">ActivityList('0000303019')</title>
<updated>2013-10-31T10:31:48Z</updated>
<category term="ZS_ESCALATIONS.Activities" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="ActivityList('0000303019')" rel="edit" title="Activities"/>
<link href="ActivityList('0000303019')/PartiesInvolved" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PartiesInvolved" type="application/atom+xml;type=feed" title="PartiesInvolved"/>
<link href="ActivityList('0000203012')/ActivityCases" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ActivityCases" type="application/atom+xml;type=feed" title="ActivityCases"/>
<link href="ActivityList('0000303019')/ActivityNotes" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ActivityNotes" type="application/atom+xml;type=feed" title="ActivityNotes"/>
<content type="application/xml">
<m:properties>
<d:activity_id>0000203012</d:activity_id>
<d:activity_process_type>ZS46</d:activity_process_type>
<d:activity_process_type_description>Req.Backoff. Assist.</d:activity_process_type_description>
<d:activity_description>gatewaytest</d:activity_description>
<d:activity_priority>Medium</d:activity_priority>
<d:activity_service_team>0004659231</d:activity_service_team>
<d:activity_status>New</d:activity_status>
<d:activity_person_resp>0004838920</d:activity_person_resp>
<d:activity_person_name>Andie Chen</d:activity_person_name>
<d:activity_activity_partner/>
<d:activity_reason/>
<d:activity_reason_desc/>
<d:activity_result_desc/>
<d:activity_cat>Z56</d:activity_cat>
<d:activity_cat_desc>Unassigned</d:activity_cat_desc>
<d:activity_change_date>2013-04-15T00:00:00</d:activity_change_date>
<d:activity_create_date>2013-04-15T00:00:00</d:activity_create_date>
<d:activity_change_time>PT06H23M15S</d:activity_change_time>
<d:activity_create_time>PT06H19M39S</d:activity_create_time>
<d:activity_planned_date>2013-04-15T00:00:00</d:activity_planned_date>
<d:activity_actual_date m:null="true"/>
<d:activity_date_duration>30</d:activity_date_duration>
<d:activity_time_unit>MINUTE</d:activity_time_unit>
<d:activity_external_number/>
<d:activity_location/>
<d:activity_sales_org/>
</m:properties>
</content>
</entry>
Kind Regards
Andie
Andie, you can drop the part:
<id>http://pgxmain.wdf.sap.corp:1080/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList('0000203012')</id>
<title type="text">ActivityList('0000303019')</title>
<updated>2013-10-31T10:31:48Z</updated>
<category term="ZS_ESCALATIONS.Activities" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="ActivityList('0000303019')" rel="edit" title="Activities"/>
<link href="ActivityList('0000303019')/PartiesInvolved" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/PartiesInvolved" type="application/atom+xml;type=feed" title="PartiesInvolved"/>
<link href="ActivityList('0000203012')/ActivityCases" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ActivityCases" type="application/atom+xml;type=feed" title="ActivityCases"/>
<link href="ActivityList('0000303019')/ActivityNotes" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ActivityNotes" type="application/atom+xml;type=feed" title="ActivityNotes"/>
from the xml. It's not required, as it's associated feed data rather than the properties.
If you use the Gateway client in SAP, it has an option to check XML posted into the body.
If your GET_ENTITYSET method is being called, please make sure you have used a POST verb rather than GET again. There is no way the OData handler will call a verb handler that isn't indicated by the request verb.
You must also return the entity content back through ER_ENTITY after creating it, otherwise you will most likely get a failure, because you have a lot of dates in the entity.
Hi Ron,
I copy and paste your xml in Gateway Client as below, and click on 'Check Request XML' button, then get error message with 'Function only for XML data available'.
And I also copy it to REST Client in Firefox browser as below, and get error message with '
The specified HTTP method is not allowed for the resource identified by the Data Service Request URI'.
Kind Regards
Andie
Hi Andie,
For the error "The specified HTTP method is not allowed for the resource identified by the Data Service Request URI'. look at this blog.
Search for the error. Problem is with your URI.
Thanks
Krishna
Hi Krishna,
For a ‘POST’ method URI should point to a Collection.
Example: …../sap/opu/odata/<NameSpace>/<ServiceName>/<CollectionName>
Now I use the following URL to create a new activity, does 'ActivityList' belong to collection name? You can see its definition in the class in my reply as below.
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList('0000303019')
Kind Regards
Andie
Yes,
Your URI for POST would be
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList
Note: Key is not mentioned.
Thanks
Krishna
Hi Ron,
Now I am using XML checker in SAPGUI to do check, but get error messge with 'Error while parsing an XML stream: '<EOF>'. Do you know how to correct this error?
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://pgxmain.wdf.sap.corp:1080/sap/opu/odata/sap/ZS_ESCALATIONS/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<content type="application/xml">
<m:properties>
<d:activity_id>0000203012</d:activity_id>
<d:activity_process_type>ZS46</d:activity_process_type>
<d:activity_process_type_description>Req.Backoff. Assist.</d:activity_process_type_description>
<d:activity_description>gatewaytest</d:activity_description>
<d:activity_priority>Medium</d:activity_priority>
<d:activity_service_team>0004659231</d:activity_service_team>
<d:activity_status>New</d:activity_status>
<d:activity_person_resp>0004838920</d:activity_person_resp>
<d:activity_person_name>Andie Chen</d:activity_person_name>
<d:activity_activity_partner/>
<d:activity_reason/>
<d:activity_reason_desc/>
<d:activity_result_desc/>
<d:activity_cat>Z56</d:activity_cat>
<d:activity_cat_desc>Unassigned</d:activity_cat_desc>
<d:activity_change_date>2013-04-15T00:00:00</d:activity_change_date>
<d:activity_create_date>2013-04-15T00:00:00</d:activity_create_date>
<d:activity_change_time>PT06H23M15S</d:activity_change_time>
<d:activity_create_time>PT06H19M39S</d:activity_create_time>
<d:activity_planned_date>2013-04-15T00:00:00</d:activity_planned_date>
<d:activity_actual_date m:null="true"/>
<d:activity_date_duration>30</d:activity_date_duration>
<d:activity_time_unit>MINUTE</d:activity_time_unit>
<d:activity_external_number/>
<d:activity_location/>
<d:activity_sales_org/>
</m:properties>
</content>
Hi Ron,
I know how to correct this xml error by adding </entry> at the end of this XML as below. Now there is no error after doing check, XML is well-formed. But I still get error message with 'The server is refusing to process the request because the entity has a unsupported format'. See the below.
I am using the following URL, is it correct?
https://pgxmain.wdf.sap.corp/sap/opu/odata/sap/ZS_ESCALATIONS/ActivityList
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://pgxmain.wdf.sap.corp:1080/sap/opu/odata/sap/ZS_ESCALATIONS/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<content type="application/xml">
<m:properties>
<d:activity_id>0000303019</d:activity_id>
<d:activity_process_type>ZS46</d:activity_process_type>
<d:activity_process_type_description>Req.Backoff. Assist.</d:activity_process_type_description>
<d:activity_description>gatewaytest</d:activity_description>
<d:activity_priority>Medium</d:activity_priority>
<d:activity_service_team>0004659231</d:activity_service_team>
<d:activity_status>New</d:activity_status>
<d:activity_person_resp>0004838920</d:activity_person_resp>
<d:activity_person_name>Andie Chen</d:activity_person_name>
<d:activity_activity_partner/>
<d:activity_reason/>
<d:activity_reason_desc/>
<d:activity_result_desc/>
<d:activity_cat>Z56</d:activity_cat>
<d:activity_cat_desc>Unassigned</d:activity_cat_desc>
<d:activity_change_date>2013-04-15T00:00:00</d:activity_change_date>
<d:activity_create_date>2013-04-15T00:00:00</d:activity_create_date>
<d:activity_change_time>PT06H23M15S</d:activity_change_time>
<d:activity_create_time>PT06H19M39S</d:activity_create_time>
<d:activity_planned_date>2013-04-15T00:00:00</d:activity_planned_date>
<d:activity_actual_date m:null="true"/>
<d:activity_date_duration>30</d:activity_date_duration>
<d:activity_time_unit>MINUTE</d:activity_time_unit>
<d:activity_external_number/>
<d:activity_location/>
<d:activity_sales_org/>
</m:properties>
</content>
</entry>
Andie, did you check the log as described here https://help.sap.com/saphelp_gateway20sp05/helpdata/en/d8/8afed0c41e4c4593b5ecd48e8f2f76/frameset.ht...
Hi Ron,
Currently, I am developing one App on iPad device based on IOS. For Query operation, I can only use its URL connecting to Gateway Service to do search in IOS, but for Create and Update operation, except for URL, also need to involved some strings like Token ID as Header values and XML file, how to use it in IOS? Do you know more about it?
Kind Regards
Andie
Hii Ron,
I am trying to POST entry but Getting the error:
error message: "Resource not found for the segment 'z_hrms_mobile_rfccollection'.", language code: "en"
I am using fololowing URL
SDMHttpRequest *request = [[SDMHttpRequest alloc] initWithURL:[NSURL URLWithString:@"http://10.9.0.30:8000/sap/opu/odata/sap/ZHRMS/z_hrms_mobile_rfccollection"]];
[request setUsername:@"ebutech"];
[request setPassword:@"initial"];
request.delegate = self;
[request addRequestHeader:@"Content-Type" value:@"application/atom+xml;type=entry"];
[request addRequestHeader:@"X-CSRF-Token" value:[dic objectForKey:@"X-CSRF-Token"]];
[request setDidFailSelector:@selector(PostFailed:)];
[request setDidFinishSelector:@selector(PostFinished:)];
[request setRequestMethod:@"POST"];
[request setPostBody:bodyData];
[request startAsynchronous];
Hi Krishna,
I am consuming ODAta services in Ios App...GET operation is working...But getting error while POST operation
error message: "Resource not found for the segment 'z_hrms_mobile_rfccollection'.", language code: "en"
I am using fololowing URL
SDMHttpRequest *request = [[SDMHttpRequest alloc] initWithURL:[NSURLURLWithString:@"http://10.9.0.30:8000/sap/opu/odata/sap/ZHRMS/z_hrms_mobile_rfccollection"]];
[request setUsername:@"username"];
[request setPassword:@"password"];
request.delegate = self;
[request addRequestHeader:@"Content-Type"value:@"application/atom+xml;type=entry"];
[request addRequestHeader:@"X-CSRF-Token" value:[dic objectForKey:@"X-CSRF-Token"]];
[request setDidFailSelector:@selector(PostFailed:)];
[request setDidFinishSelector:@selector(PostFinished:)];
[request setRequestMethod:@"POST"];
[request setPostBody:bodyData];
[request startAsynchronous];
here it is metadata
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<PropertyRef Name="docnr"/>
</Key>
<Property Name="endda" Type="Edm.DateTime" sap:label="End Date" sap:updatable="false"/>
<Property Name="pernr" Type="Edm.String" Nullable="false" MaxLength="8" sap:label="Personnel number" sap:updatable="false"/>
<Property Name="anrtg" Type="Edm.Decimal" Precision="6" Scale="2" sap:label="Days credited" sap:creatable="false" sap:updatable="false"/>
<Property Name="begda" Type="Edm.DateTime" sap:label="Start Date" sap:updatable="false"/>
<Property Name="employeenumber_1" Type="Edm.String" MaxLength="8" sap:label="Personnel Number" sap:creatable="false" sap:updatable="false"/>
<Property Name="nocommit" Type="Edm.String" MaxLength="1" sap:label="COMMIT flag in BAPI interface" sap:updatable="false"/>
<Property Name="absencetype" Type="Edm.String" MaxLength="4" sap:label="Att./Absence type" sap:creatable="false" sap:updatable="false"/>
<Property Name="abwtg" Type="Edm.Decimal" Precision="6" Scale="2" sap:label="Att./abs. days" sap:creatable="false" sap:updatable="false"/>
<Property Name="awart" Type="Edm.String" MaxLength="4" sap:label="Att./Absence type" sap:updatable="false"/>
<Property Name="iv_docnr" Type="Edm.String" MaxLength="20" sap:label="Document number" sap:creatable="false" sap:updatable="false"/>
<Property Name="status" Type="Edm.String" MaxLength="10" sap:label="status" sap:creatable="false" sap:updatable="false"/>
<Property Name="docnr" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Document number" sap:creatable="false" sap:updatable="false"/>
<Property Name="subty" Type="Edm.String" MaxLength="4" sap:label="Subtype" sap:creatable="false" sap:updatable="false"/>
<Property Name="kaltg" Type="Edm.Decimal" Precision="6" Scale="2" sap:label="Calendar days" sap:creatable="false" sap:updatable="false"/>
<Property Name="stdaz" Type="Edm.Decimal" Precision="7" Scale="2" sap:label="Absence hours" sap:creatable="false" sap:updatable="false"/>
<Property Name="plans" Type="Edm.String" MaxLength="8" sap:label="Position" sap:creatable="false" sap:updatable="false"/>
<Property Name="reason" Type="Edm.String" MaxLength="30" sap:label="Reason for leave" sap:updatable="false"/>
<NavigationProperty Name="it_ypa2001_r" Relationship="ZHRMS.it_ypa2001_r" FromRole="FromRole_it_ypa2001_r" ToRole="ToRole_it_ypa2001_r"/>
</EntityType>
Sorry Ron,previously i sent u incpmlete data
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<End Type="ZHRMS.it_ypa2001" Multiplicity="*" Role="ToRole_it_ypa2001_r"/>
</Association>
<EntitySet Name="it_ypa2001Collection" EntityType="ZHRMS.it_ypa2001" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1"/>
<End EntitySet="it_ypa2001Collection" Role="ToRole_it_ypa2001_r"/>
</AssociationSet>
</EntityContainer>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="self" href="http:///sap/opu/odata/sap/ZHRMS/$metadata"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="latest-version" href="http:///sap/opu/odata/sap/ZHRMS/$metadata"/>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
OK, I see the problem now. Your URI is not in the same case - OData URI's are case sensitive, i.e..
http://10.9.0.30:8000/sap/opu/odata/sap/ZHRMS/z_hrms_mobile_rfcCollection
Hi Ron,
I want to do PUT(update) operation on odataservice... I am using followin code to get the proper Entry property to update
SDMODataEntry * entry1=((SDMODataEntry *)[ArraySelectedCell objectAtIndex:0]);
SDMODataPropertyValueObject* obj = ((SDMODataPropertyValueObject*)[entry1 getPropertyValueByPath:@"rm_comment"]);
But i am getting following error
__NSDictionaryM getPropertyValueByPath:]: unrecognized selector sent to instance 0x10166620
Please help...
Regards,
Ravindra
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.