Tejaswi

error while setting reminder

0 votes

Hi,

Getting the below error for reminder. package is in draft status. 

400
Bad Request
HTTP/1.1
Response body>{"messageKey":"error.validation.invalidJson","technical":"Failed to deserialize json string to target type com.silanis.esl.api.model.PackageReminderSchedule","message":"Invalid JSON.","code":400,"name":"Validation Error"}


Kindly assist


Reply to: error while setting reminder

0 votes

Hi Tejaswi,

 

You can find the JSON schema for "PackageReminderSchedule" object in our API specification site, and a real example looks like below:

{
  "packageId": "cPl9HE-ENGzkwRJxKlEURNH4LD4=",
  "startInDaysDelay": 1,
  "repetitionsCount": 2,
  "intervalInDays": 3
}

Could you print out your outbound request body and compare against this schema?

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: error while setting reminder

0 votes

Hi Duo, 
 

The request body provided by you is same as the one used by me. 

below is the request body used in my code:
 

 l_request_body :=  l_newline || l_newline || '--' || lco_boundary || l_newline ||
                        'Content-Disposition: form-data; name="payload"' || l_newline || l_newline ||'{
                                "packageId": "hY13rlhF1edO9mL17F_QREtgNew=",
                                "startInDaysDelay": 1,
                                "repetitionsCount": 2,
                                "intervalInDays": 3
                                }' || l_newline || '--' ||
                    lco_boundary || '--';

 

Is there any other thing that should be passed in request body?

 


Reply to: error while setting reminder

0 votes

I see. In stead of setting content type as multipart/form-data and add the JSON as a form named "payload", you would setting the content type as "application/json" and directly output the payload, with codes around these lines:

  req := utl_http.begin_request(url, 'POST',' HTTP/1.1');

  utl_http.set_header(req, 'content-type', 'application/json');

  utl_http.set_header(req, 'Content-Length', length(content));

 

  utl_http.write_text(req, content);

  res := utl_http.get_response(req);

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: error while setting reminder

0 votes

what is content in length(content)? should it be declared as a variable and what data type?
i asked because the code is giving error saying content must be declared.
 

utl_http.set_header(l_http_request, 'Accept', 'application/json');
  utl_http.set_header(l_http_request, 'Content-Type', 'application/json');
  utl_http.set_header(l_http_request, 'Content-Length', length(content));
  
  
  l_request_body := '{
                                "packageId": "hY13rlhF1edO9mL17F_QREtgNew=",
                                "startInDaysDelay": 1,
                                "repetitionsCount": 2,
                                "intervalInDays": 3
                                }'/;

  l_request_body_length := dbms_lob.getlength(l_request_body);

  utl_http.write_text(l_http_request, content);

  l_http_response := utl_http.get_response(l_http_request);
 utl_http.read_text(l_http_response, l_response_body, 32767);


Reply to: error while setting reminder

0 votes

I think you can simply remove this request header since it's not mandatory.

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: error while setting reminder

0 votes

Still getting the same error.
 

url : https://sandbox.esignlive.com/api/packages/hY13rlhF1edO9mL17F_QREtgNew/reminders

Code:

  utl_http.set_wallet(l_cert_path, 'wallet_pwd');
  l_http_request := utl_http.begin_request(l_endpoint_prod_url,
                                           'POST',
                                           'HTTP/1.1');

  ----providing authorization to esign account using api key
  utl_http.set_header(l_http_request,
                      NAME           => 'Authorization',
                      VALUE          => l_api_key);

  utl_http.set_header(l_http_request, 'Accept', 'application/json');
  utl_http.set_header(l_http_request, 'Content-Type', 'application/json');
  
  
  l_request_body := '{"packageId": "hY13rlhF1edO9mL17F_QREtgNew=",
                      "startInDaysDelay": 1,
                      "repetitionsCount": 2,
                      "intervalInDays": 3
                                }';

  l_request_body_length := dbms_lob.getlength(l_request_body);
  l_offset              := 1;

  WHILE l_offset < l_request_body_length LOOP
    dbms_lob.read(l_request_body, l_amount, l_offset, l_buffer);
    utl_http.write_raw(l_http_request, utl_raw.cast_to_raw(l_buffer));
    l_offset := l_offset + l_amount;
  END LOOP;
  
  l_http_response := utl_http.get_response(l_http_request);

   utl_http.read_text(l_http_response, l_response_body, 32767);


Reply to: error while setting reminder

0 votes

Hi Tejaswi,

 

Unfortunately I have my Oracle uninstalled, may take some time to set up the environment. From my previous note, could you use function "utl_http.write_text(req, content);" rather than "utl_http.write_raw(l_http_request, utl_raw.cast_to_raw(l_buffer));"?

 

Below sample code should work where a POST call, with content-type of "application/json", is sent to create a package.

 

create or replace procedure create_package
as
  req utl_http.req;
  res utl_http.resp;
  url varchar2(4000) := 'https://sandbox.esignlive.com/api/packages';
  buffer varchar2(4000); 
  content varchar2(4000) := '{"name":"package created from oracle"}';
 
begin
  req := utl_http.begin_request(url, 'POST',' HTTP/1.1');
  utl_http.set_header(req, 'user-agent', 'mozilla/4.0'); 
  utl_http.set_header(req, 'content-type', 'application/json'); 
  utl_http.set_header(req, 'Authorization', 'Basic your_api_key'); 
  utl_http.set_header(req, 'Content-Length', length(content));
 
  utl_http.write_text(req, content);
  res := utl_http.get_response(req);
  -- process the response from the HTTP call
  begin
    loop
      utl_http.read_line(res, buffer);
      dbms_output.put_line(buffer);
    end loop;
    utl_http.end_response(res);
  exception
    when utl_http.end_of_body 
    then
      utl_http.end_response(res);
  end;
end create_package;
/

 

Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: error while setting reminder

0 votes

yes the above code is working. If I added the request body , after content lenght line, will the reminder schedule for the intended package?

If the package for which i want to set reminder is in SENT status, which request type should i use for scheduling reminder? (the package has no reminder set earlier)

Is it compusory for a package to be in DRAFT status for scheduling a reminder via POST request?

 


Reply to: error while setting reminder

0 votes

Yes, the request body should be the reminder schedule JSON.

 

If the package for which i want to set reminder is in SENT status, which request type should i use for scheduling reminder? (the package has no reminder set earlier)

You can also set reminder when the package is in DARFT status, either to set reminder at the time place, or to update an existing reminder schedule, you could use POST call. (both PUT and POST works for updating)

 

Is it compusory for a package to be in DRAFT status for scheduling a reminder via POST request?

Yes, to set up reminder in DRAFT status is compusory.

 

Duo

 

Duo Liang OneSpan Evangelism and Partner Integrations Developer


Reply to: error while setting reminder

0 votes

I ran the above code 3 times for reminder and 3 transactions were created in draft status with package id as transaction name. 
this will saturate the drafts folder for every schdeuled reminder. Can I delete these transactions? By deleting these transactins does the reminder also gets deleted?

PFA


Attachments
reminder.PNG21.26 KB

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off