REST API POST Response is coming null for Java Service in Postman

Hi,
I have created Document Reference Request & Response in Input/Output Parameter in Java Service. I have generated Java Code which is modified to map the right attributes,
Request:

 {
 	"Sender": "Buyer1",
 	"Orders": [{
 		"OrderID": "100",
 		"SKU": "01",
 		"UnitPrice": "100",
 		"Quantity": "20"
 	}]
 }

Response:

 {
     "Sender": "Buyer1",
     "Orders": [
         {
             "OrderID": "100",
             "SKU": "01",
             "UnitPrice": "100",
             "Quantity": "20"
         }
     ],
     "Response": {
         "Response": {
             "Customer": null,
             "Orders": [
                {
                     "OrderID": null,
                     "AmountDue": null
                 }
             ]
         }
     }
 }

Can someone guide me why null is coming in Response in POSTMAN?

Thanks!

Hi @harleen.kaur

Could you please post some screenshots of your flow or attached a word document with all screenshots if there are many?

Thanks and Regards
Prasad Pokala

Creating a Java Service.docx (93.1 KB)

@Prasad_Pokala Attached document with all the details.

Let me know if anything else required.

Thanx!

1 Like

Hey, @harleen.kaur

Just seems like small issue. I guess the control is not going inside the for loop where OrderId and UnitPrice are being assigned.
Can you put println steps before and after it as below?

                       if ( Orders != null)
							{
                                System.out.println("***** Inside IF, Before Loop *****");
								for ( int i = 0; i < Orders.length; i++ )
								{
                                    System.out.println("***** Inside Loop *****");
									IDataCursor OrdersCursor = Orders[i].getCursor();

Monitor if you are seeing any of these logs being printed in the “wrapper.log” file of your IS.
If they are not, then it means control is not even going till there… some control is not even going there… so keep debugging until you find which if statement is culprit…

1 Like

I have checked the logs and find out its not going to print statement. I put print statement above and find out that request is giving null.

System.out.println("***** Test *****");
			// Request
			IData	Request = IDataUtil.getIData( pipelineCursor, "Request" );
			System.out.println("***** Request *****" + Request);
			if ( Request != null)
			{
				IDataCursor RequestCursor = Request.getCursor();

Harleen,

Your issue is about sending input parameters to the service.

You are using the /ìnvoke/ form. This method does’nt support JSONs. as input.
Options: either

  • use the /restv2/ form - if you want to keep the JSON input data, or
  • keep the using the /invoke/form; in this case have to change the input data format to XML.

References (straightly about the subject):

  • “Creating a Client that Submits an XML Document via HTTP”, in Service Development Help.pdf.
  • “Example of Defining a REST V2 Resource Operation”, in Service Development Help.pdf.

For broader info, please refer to the topics:

  • “Submitting and Receiving XML Documents”, in Service Development Help.pdf
  • “Working with REST”, in Service Development Help.pdf

I am to resolve the issue.

Thanx!!