error while setting reminder
Wednesday, November 11, 2020 at 02:44amHi,
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
Wednesday, November 11, 2020 at 09:14amHi 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
Reply to: error while setting reminder
Wednesday, November 11, 2020 at 11:27amHi 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
Wednesday, November 11, 2020 at 11:40amI 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
Reply to: error while setting reminder
Wednesday, November 11, 2020 at 11:52amwhat 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
Wednesday, November 11, 2020 at 12:13pmI think you can simply remove this request header since it's not mandatory.
Duo
Reply to: error while setting reminder
Wednesday, November 11, 2020 at 12:18pmStill 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
Wednesday, November 11, 2020 at 12:30pmHi 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
Reply to: error while setting reminder
Wednesday, November 11, 2020 at 12:50pmyes 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
Wednesday, November 11, 2020 at 12:57pmYes, 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
Reply to: error while setting reminder
Wednesday, November 11, 2020 at 01:21pmI 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