on 06-17-2016 7:36 PM
Hello
I am trying to implement POST operation with GWSAMPLE_BASIC and Business Partner Entity Set. Here is my code:
Init Method:
self=this;
var surl = "proxy/http/sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/";
var omodel = new sap.ui.model.odata.v2.ODataModel(surl,true);
omodel.setDefaultBindingMode("TwoWay");
sap.ui.getCore().setModel(omodel);
onPress: function()
{
var bpId = this.getView().byId("i1").getValue();
var cname = this.getView().byId("i2").getValue();
var tbl = self.getView().byId("idbp");
var x =
{
"BusinessPartnerID": bpId,
"CompanyName": cname,
"EmailAddress":"abc@yahoo.com",
"WebAddress":"http://www.google.com",
"PhoneNumber":"+111111",
"FaxNumber":"+111111",
"LegalForm":"AG",
"CurrencyCode":"USD",
"BusinessPartnerRole":"01",
"Address": {
"City":"Chicago",
"PostalCode":"60004",
"Building":"47",
"Street":"Rand Road",
"Country":"US",
"AddressType":"02",
},
} ;
var url = "proxy/http/sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/";
var method= "POST";
var requestObj = {
requestUri: '',
method: '',
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/json",
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0",
"Accept": "application/json"
} };
requestObj.requestUri = url;
requestObj.method = method;
requestObj.data = x;
OData.request(requestObj, function() {
alert("Success");
});
},
I was still editing it clicked Saved by mistake.
View:
<content>
<Input id="i1" value="" width="200px" />
<Input id="i2" value="" width="200px" />
<Button text="Add" press="onPress" />
<Table id="idbp" items="{/BusinessPartnerSet}">
<columns>
<Column>
<Text text="BusinessPartnerID" />
</Column>
<Column>
<Text text="Company Name" />
</Column>
<Column>
<Text text="City" />
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{BusinessPartnerID}" />
<Text text="{CompanyName}" />
<Text text="{Address/City}" />
</cells>
</ColumnListItem>
</items>
</Table>
</content>
I get an error: "datajs.js:17 POST http://localhost:60901/odata_post/proxy/http/sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BA... 403 (Forbidden)"
I think GWSAMPLE_BASIC supports CRUD operation so POST should work. Is there anything wrong with code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
then what?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.