NCRCounterpointAPI / APIGuide

Repository for NCR Counterpoint API Documentation
33 stars 15 forks source link

Not able to create an Order using POST https://886-1073:52000/Document API. Getting error as "500 Internal Server Error" #108

Open asgarh opened 6 years ago

asgarh commented 6 years ago

Hi Support Team,

We tried to create an order using NCR Counterpoint API but we are not able to create an order in NCR Counterpoint POS. Please find below request/response.

We are using the below API POST https://886-1073:52000/Document

-------------------------------- Request/Response ---------------------------------------- POST https://886-1073:52000/Document HTTP/1.1 Accept: application/json Authorization: Basic VEVTV---------------------sQDEyMzQ1 APIKey: RTEm---------------------------------SC0i Content-Type: application/json; charset=utf-8 Host: 886-1073:52000

{ "PS_DOC_HDR": { "STR_ID": "MAIN", "STA_ID": "1", "DRW_ID": "1", "TKT_TYP": "T", "DOC_TYP": "O", "USR_ID": "MGR", "PS_DOC_NOTE": [ { "NOTE_ID": "TEST", "NOTE": "This is a note!" } ], "PS_DOC_LIN": [ { "LIN_TYP": "O", "ITEM_NO": "ADM-SCD", "PRC":"200", "USR_ENTD_PRC":"Y", "QTY_SOLD": "1.0" } ], "PS_DOC_PMT": [ { "PAY_COD": "VISA", "FINAL_PMT": "Y", "PS_DOC_PMT_CR_CARD": { "CR_CARD_NO": "4111111111111111", "CR_CARD_NAM": "JOHN DOE", "AVS_ZIP_COD": "12345", "CR_CARD_EXP_DAT": "12/2018" } } ], "PS_DOC_TAX": [ { "AUTH_COD": "MEMPHIS", "RUL_COD": "TAX", "TAX_DOC_PART": "O", "LIN_AMT": "200", "TXBL_LIN_AMT": "200", "TXBL_QTY": "1.00", "TAX_AMT": "4.00", "TOT_TXBL_AMT": "200" }, { "AUTH_COD": "SHELBY", "RUL_COD": "TAX", "TAX_DOC_PART": "O", "LIN_AMT": "200", "TXBL_LIN_AMT": "200", "TXBL_QTY": "1.00", "TAX_AMT": "6.00", "TOT_TXBL_AMT": "200" }, { "AUTH_COD": "TN", "RUL_COD": "TAX", "TAX_DOC_PART": "O", "LIN_AMT": "200", "TXBL_LIN_AMT": "200", "TXBL_QTY": "1.00", "TAX_AMT": "6.00", "TOT_TXBL_AMT": "200" } ] } }

HTTP/1.1 500 Internal Server Error Content-Type: application/json; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 Set-Cookie: ss-id=n3XJhifyMirCb1BHyLRE;path=/ Set-Cookie: ss-pid=bMOWLn07v6LNYTUkghSs;path=/;expires=Fri, 16 Apr 2038 09:36:56 GMT Date: Mon, 16 Apr 2018 09:36:56 GMT Content-Length: 1455

{ "ResponseStatus": { "ErrorCode": "NullReferenceException", "Message": "Object reference not set to an instance of an object.", "StackTrace": " at lambda_method(Closure , AddDocumentRequest )\r\n at ServiceStack.FluentValidation.Internal.Extensions.<>c__DisplayClass10_02.<CoerceToNonGeneric>b__0(Object x)\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy1.LazyInitValue()\r\n at ServiceStack.FluentValidation.Validators.NotNullValidator.IsValid(PropertyValidatorContext context)\r\n at ServiceStack.FluentValidation.Validators.PropertyValidator.Validate(PropertyValidatorContext context)\r\n at ServiceStack.FluentValidation.Internal.PropertyRule.<Validate>d__49.MoveNext()\r\n at System.Linq.Enumerable.<SelectManyIterator>d__172.MoveNext()\r\n at System.Collections.Generic.List1..ctor(IEnumerable1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at ServiceStack.FluentValidation.AbstractValidator1.Validate(ValidationContext`1 context)\r\n at ServiceStack.Validation.ValidationFilters.RequestFilter(IRequest req, IResponse res, Object requestDto)\r\n at ServiceStack.ServiceStackHost.ApplyRequestFiltersSingle(IRequest req, IResponse res, Object requestDto)\r\n at ServiceStack.ServiceStackHost.ApplyRequestFilters(IRequest req, IResponse res, Object requestDto)\r\n at ServiceStack.Host.RestHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)" } }

Please have a look and let us know if we are missing anyhting.

Thanks,

MikeRitchie commented 6 years ago

Could you try removing the PS_DOC_PMT portion and seeing how that impacts your result? Also I've edit out your APIKey and Authorization header as those shouldn't be posted online.

asgarh commented 6 years ago

Hi MikeRitchie,

We have removed PS_DOC_PMT portion. But we are facing same issue. Can you send me working request data. So we can try at our end.

Thank you.

asgarh commented 6 years ago

Hi Team,

Please provide us solution for this problem. It's blocker for us for our integration.

Thank you.

asgarh commented 6 years ago

Hi Team,

Can you please take a look into this. It's blocker for us for our integration.

Thank you.

tjohnson-github commented 4 years ago

Is anyone helping with this issue. I'm having same issue. Also, one thing I was thinking does the payload need to be encrypted first or encoded? I'm just using curl to test so not sure if it is encoding it? I hope...

GMHIGGINS commented 4 years ago

Is anyone helping with this issue. I'm having same issue. Also, one thing I was thinking does the payload need to be encrypted first or encoded? I'm just using curl to test so not sure if it is encoding it? I hope...

For my own project, I had to make sure that the PS_DOC_HDR section had the CUST_NO field added to it with a valid customer number from CounterPoint. I ran into that same 500 error and was only able to resolve it once I had added a valid CP customer number.

As for encryption, I did not need anything beyond generating a certificate that I installed on the client machines where my application would be run from.

tjohnson-github commented 4 years ago

@asgarh So here is my own experience with adding Document...i.e. create an order / ticket. Hope this might help some people. If your getting IEnumerable exception error. Most likely you are not encoding the json or your not putting in the .ContentType = "application/json" header part. This basically will make the body misaligned hense the reason your getting array errors. Once your past these errors and getting errors like referencing a field name then you know your past the content part. Most of the errors past this had to do with tax and making sure all my calculations were correct between price of product, amount of tax, taxable amount, total price. Also make sure any discounts are subtracted and you have the correct tax codes in there. Anyway, Hope that helps anyone.