cancel
Showing results for 
Search instead for 
Did you mean: 

GW CRM Contact Service - Bad Request

Former Member
0 Kudos

Dear all,

I'm trying to build a sample client for the  CRM Contact Service placed at GW ESWORKPLACE

I test it locally. When I run the sample app I get this error (from firebug console)

'http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection/$metadata?sap-client=800...


2012-11-26 18:22:55 The following problem occurred: HTTP request failed400,Bad Request,<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>/IWCOR/ATOM_ODATA_TX/004</code><message xml:lang="en">It is only possible to specify a filter for a feed</message><innererror>It is only possible to specify a filter for a feed.</innererror></error> -

No error if I copy&paste the ODataModel sServiceUrl directly in the browser.

Here is the relevant part of the source code

Any help? Really appreciate.

Thanks for your time and your cooperation.

Regards,

Mirco

p.s firebug console screenshot attached.

Accepted Solutions (1)

Accepted Solutions (1)

qmacro
Developer Advocate
Developer Advocate
0 Kudos

You're trying to filter on the metadata.

Remove the /$metadata part from your URL and you should be ok.

dj

Former Member
0 Kudos

Hi DJ,

The URL I pass to the ODataModel is correct, no metadata in it

var oModel = new ODataModel('http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection?sap-client=800&$format=x...', false, 'user', 'pwd');

the $metadata is displayed within the firebug console ->

"GET" http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection/$metadata?sap-client=800...

Please see the gits if you are in doubt.

Thank you,

Mirco

Vlad
Advisor
Advisor
0 Kudos

Hello Mirco,

Use the following link for ODataModel:

http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection?sap-client=800

I assume that you can safely remove sap-client:

http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection

Kind regards,

Vlad

Former Member
0 Kudos

Hi Vadislav,

I tried to remove the sap-client parameter but the result is the same

Same error reported by the client and blank empty table

It is courios that no error is reported in the backend system (/IWFND/ERROR_LOG).

Infact using a rest client or the gateway client in the backend, It works fine.

Any other advice?

Thanks for your help Vadislav

Regards,

Mirco

p.s none of you have tried to call the crm service using sapui5?

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mirco,

have you tried looking into the following transactions in the Backend?
/IWBEP/ERROR_LOG

/IWBEP/VIEW_LOG

Regards,

Carlos

Former Member
0 Kudos

Hi Carlos,

unfortunately no entry in

/IWBEP/ERROR_LOG 

/IWBEP/VIEW_LOG

I use chrome and firefox to test my app. no way with ie8.

Thanks for your support.

Regards,

Mirco

Vlad
Advisor
Advisor
0 Kudos

I think I know what is wrong.

In fact, you define the model like:

var oModel = new ODataModel('http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection?sap-client=800&$format=x...', false, 'user', 'pwd');

But the model, indeed, is a root link:

var oModel = new ODataModel('http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/', false, 'user', 'pwd');

ContactCollection is a part of bindRows. So, SAPUI will add this word at the end of the URL automatically.

But, you cannot get records from the collection, until you setup the filter.

I think, for this stuff you need either to use the full bindRows definition:

bindRows(sPath, sSorter, aFilters)

Probably, sPath is the name of your collection. sSorter is null, but aFilters is an array of a single Filter element.

I would use it like that:

oTable.bindRows("ContactCollection", null, [new sap.ui.model.Filter("ContactCollection", sap.ui.model.FilterOperator.EQ, "SearchTerm", "Gateway")]);

but I cannot setup my development environment properly to make it work

What do you think about this?

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mirco,

Vlad's proposal looks very promising.

I'd just like to comment:

Would it be possible to switch to the odata branch (instead of sdata: /sap/opu/odata/iwcnt/contact)? (Is the ICF node activated?)

This will provide better error handling, an entry in error_log, including navigation to apps_log which allows to check the stack trace in order to start debugging.

Kind regards,

Carlos

Former Member
0 Kudos

Hi  Vadislav, it is exactly  what  i'm trying to test now

I keep you updated

Thanks a lot

Regards,

Mirco

Former Member
0 Kudos

Hi Vadislav,

what to say, it works!

Thanks for your fixing. Really appreciate.

Here the source code updated

Regards,

Mirco

Answers (1)

Answers (1)

jibin_joy
Contributor
0 Kudos

Hi Mirco,

  

   I dont think so its problem with SAP Gateway .  Based on the Firbug Screen shot as posted above . We can see the Request is gone with "$metadata" .

    Wht ever request we see in the firebug are the actual request send to the SAP Gateway server  and for confirmation just see SAP Gateway Trace Log from which we can  observe the request hit to the Gateway Server ...

   SAP Gateway Trace Log : http://www.youtube.com/watch?v=Hg6J3Kfiw0M

and if we go to direct URL

http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/contact/ContactCollection?sap-client=800&$format=x...

  This is Working fine..

My observation says that the plm is in UI Level coding

Hope it Help u

Regards,

Jibin Joy

Former Member
0 Kudos

Hi Jibin,

I am agree with you.

Thanks for your support.

Regards,

Mirco

Vlad
Advisor
Advisor
0 Kudos

I think I managed this problem.

My code in the index.html file is the following

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Gateway presentation</title>

<script id="sap-ui-bootstrap" type="text/javascript"
src="sapui5/resources/sap-ui-core-dbg.js"
data-sap-ui-theme="sap_goldreflection"
data-sap-ui-libs="sap.ui.commons,sap.ui.table,sap.ui.ux3"></script>

<script type="text/javascript">
var oModel = (function(uri, service, user, password) {
  var dflt_uri = uri || "http://gw.esworkplace.sap.com/sap/opu/sdata/iwcnt/";
  var dflt_service = service || "contact";

  var oModel = new sap.ui.model.odata.ODataModel(dflt_uri + dflt_service,
    false, "GW@ESW", "ESW4GW");

  return {
   getModel : function() {
    return oModel;
   },
   getMetadata : function() {
    return oModel.oMetadata.dataServices.schema[0];
   }
  }
}());

function BuildTable(oModel) {
  var oTable = new sap.ui.table.DataTable({
   columns : [ {
    label : "Value:",
    template : "Value"
   }, {
    label : "First Name:",
    template : "FirstName"
   }, {
    label : "Last Name",
    template : "LastName"
   } ]
  });

  // bind model to Table
  oTable.setModel(oModel.getModel());
  oTable.bindRows("/ContactCollection", null, [new sap.ui.model.Filter("SearchTerm", sap.ui.model.FilterOperator.EQ, "Gateway")]);

  return oTable;
};

$(document).ready(function() {
  var oTable = BuildTable(oModel);
  oTable.setThreshold(10);
  oTable.setVisibleRowCount(10);
  oTable.placeAt("placeArea");
});
</script>
<body class="sapUiBody">
<div id="placeArea"></div>
</body>
</html>

I simply bound the model to the root of the OData webservice. And then applied filters for DataTable.

p.s. sorry guys, I have to go. I will respond tomorrow.