-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCreateProductInErpWithBasicAuthentication.js
56 lines (52 loc) · 1.58 KB
/
CreateProductInErpWithBasicAuthentication.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const cdsapi = require("@sapmentors/cds-scp-api");
// -----------------------------------------------------------------------------------------------------
// Calling Internet API with Basic Authentication using SCP Destinations to create a product:
// HTTP method: POST
// Destination settings
// - Name : ES5
// - Proxy Type : Internet
// - Authentication : BasicAuthentication
// -----------------------------------------------------------------------------------------------------
async function InternetAPIPostRequestwithBasicAuthorization(_product) {
const service = await cdsapi.connect.to("ES5");
return await service.run({
url: "/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/ProductSet",
method: "post",
headers: {
'content-type': 'application/json'
},
data: _product,
csrfProtection: true
})
}
InternetAPIPostRequestwithBasicAuthorization(
{
"ProductID": "YourProductID", //Please change this value before running
"TypeCode": "PR",
"Category": "Notebooks",
"Name": "Psychiatric Help",
"NameLanguage": "EN",
"Description": "",
"DescriptionLanguage": "",
"SupplierID": "0100000000",
"SupplierName": "SAP",
"TaxTarifCode": 1,
"MeasureUnit": "EA",
"WeightMeasure": "0.000",
"WeightUnit": "",
"CurrencyCode": "EUR",
"Price": "0.05",
"Width": "0.000",
"Depth": "0.000",
"Height": "0.000",
"DimUnit": "",
"CreatedAt": "\/Date(1602106635169)\/",
"ChangedAt": "\/Date(1602106635169)\/"
}
)
.then((resp) => {
console.log('Post request')
console.log(resp)
}).catch(error => {
console.log(error)
})