cancel
Showing results for 
Search instead for 
Did you mean: 

Business Rule - Import rule expressions

JérémyChabert
Participant
0 Kudos

Hello,

While using the following API method => POST /v1/import/rules, i struggle to make it work in my custom application.

I followed the code snippet and i'm able to reach endpoint as expected, however, the import fails with error code 500


error: {code: "bpm.rulesrepository.internalservererror",…}

code: "bpm.rulesrepository.internalservererror"

details: []

message: "Content type 'text/plain;charset=UTF-8' not supported"


I don't what know what i should precise as content type in my request in order to make it work.

So far, i tried :

"application/json"

"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

Without success.

I took a look while debugging the service SAP Cloud Platform Business Rules and I'm doing exactly as it is done in this service.

The only difference resides in the URL used which is a bit different :

uploadUrl: "./rules-service/rest/internal/v1/import/projects/{id}/rules/{rulesid}"

Here's my code attached to a Upload Button with a FileUploader component

Here's the code in SAP Cloud Platform Business Rules

Do you have any clues or examples of using this specific API method where it actually works ?

I'm looking forward for any help you can provide.

Accepted Solutions (0)

Answers (1)

Answers (1)

Archana
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Jeremy,

This should be simple. You can use file uploader control in your application to browse and select the file and then through following Ajax call syntax you can call Rules Import API:

$.ajax({
  url: "/v1/import/rules",
  method: "POST",
  processData: false,
  headers: {
    "Slug": file.name,
    "Content-Type": file.type,
    "Accept": "application/json"
  },
  data: file,
  success: function(result, xhr, data){
  }
})
JérémyChabert
Participant
0 Kudos

Edit 23 nov:

Hello Archana.

I will share the results of my attempt to community.

I tried as you suggested, as a result, I don't raise the format issue anymore which is a step into the right path

BUT i still get the HTTP code 500 without info this time. Just a plain Internal server error.

I tried my xlsx file using the standard service application and it worked fine, so it doesn't seems to come from the content of my file.

———————————

Hello Archana,

I will try it and come back to you as soon as possible.

Thansk for the answer.