Hi,
Newbie in API custom webservice thing. I created my custom web service, contain these classes :
1. class TestAPIRequest, contain the data contract attribute
2. class TestAPIResponse, contain response message and success or not
3. class TestAPIService, contain the logic based on the request and return the response.
As per my understanding, in normal case will be something like this (for illustration only) :
1. class TestAPIRequest
[DataContractAttribute]class TestAPIRequest{ private str dataAreaId; private str journalNum; [DataMember(/DataAreaId/)] public str parmDataAreaId(str _value = dataAreaId) { if (!prmIsDefault(_value)) { dataAreaId = _value; } return dataAreaId; } [DataMember(/JournalNumber/)] public str parmJournalNumber(str _value = journalNumber) { if (!prmIsDefault(_value)) { journalNumber= _value; } return journalNumber; }}
2. class TestAPIResponse
[DataContractAttribute]class TestAPIResponse{ private boolean success; private str message; [DataMember(/Success/)] public boolean parmSuccess(boolean _value = success) { if (!prmIsDefault(_value)) { success = _value; } return success; } [DataMember(/Message/)] public str parmMessage(str _value = message) { if (!prmIsDefault(_value)) { message = _value; } return message; }}
3. class TestAPIService
public class TestAPIService{ public TestAPIResponse postJournal(TestAPIRequest _request) { try { var response = new TestAPIResponse(); changecompany(_request.parmDataAreaId()) { .... code.... } response.parmMessage(/Posted/); response.parmSuccess(true); } catch { response.parmMessage(/Error/); response.parmSuccess(false); } return response; }}
Then I've created the ServiceGroup, Services which then available to be called from Postman. In Postman, basically I will put JSON string in the Body, something like:
{ /_request/: { /DataAreaId/: /TEST/, /JournalNumber/ : /JN000730/ }}
Question is: if I want to retrieve the request JSON string, when the service class is called, how am I gonna do that ? The intention is I want to keep the JSON string as a string in one of my table for history.
May I have a guide here. What need to be done ? how ? and where to put ?
Thanks