Visual Studio & Material Issue & REST

Ok, so, I have managed to get a bit further, using josecgomez code after the response code i could see i was missing some parameters.
I am now getting a different error, not sure if it is because I am using a custom method?

{
  "RequestURI": "https://kinetic/KineticTest/api/V1/Erp.BO.IssueReturnSvc/GetNewIssueReturn",
  "Response": {
    "Request": {
      "AlwaysMultipartFormData": false,
      "MultipartFormQuoteParameters": false,
      "FormBoundary": null,
      "Parameters": [
        {
          "Name": "License",
          "Value": "{\"ClaimedLicense\":\"00000003-b615-4300-957b-34956697f040\"}",
          "Type": 2,
          "Encode": false,
          "ContentType": null
        },
        {
          "Name": "cache-control",
          "Value": "no-cache",
          "Type": 2,
          "Encode": false,
          "ContentType": null
        },
        {
          "Name": "authorization",
          "Value": "Basic dHJhY3ljOlNwNHJrbGVz",
          "Type": 2,
          "Encode": false,
          "ContentType": null
        },
        {
          "Name": "contextheader",
          "Value": "{\"Context\":{\"BpmData\":[{\"Password\":\"\",\"ButtonValue\":0,\"Character01\":\"\",\"Character02\":\"\",\"Character03\":\"\",\"Character04\":\"\",\"Character05\":\"\",\"Character06\":\"\",\"Character07\":\"\",\"Character08\":\"\",\"Character09\":\"\",\"Character10\":\"\",\"Character11\":\"\",\"Character12\":\"\",\"Character13\":\"\",\"Character14\":\"\",\"Character15\":\"\",\"Character16\":\"\",\"Character17\":\"\",\"Character18\":\"\",\"Character19\":\"\",\"Character20\":\"\",\"Number01\":0.0,\"Number02\":0.0,\"Number03\":0.0,\"Number04\":0.0,\"Number05\":0.0,\"Number06\":0.0,\"Number07\":0.0,\"Number08\":0.0,\"Number09\":0.0,\"Number10\":0.0,\"Number11\":0.0,\"Number12\":0.0,\"Number13\":0.0,\"Number14\":0.0,\"Number15\":0.0,\"Number16\":0.0,\"Number17\":0.0,\"Number18\":0.0,\"Number19\":0.0,\"Number20\":0.0,\"Checkbox01\":false,\"Checkbox02\":false,\"Checkbox03\":false,\"Checkbox04\":false,\"Checkbox05\":false,\"Checkbox06\":false,\"Checkbox07\":false,\"Checkbox08\":false,\"Checkbox09\":false,\"Checkbox10\":false,\"ShortChar01\":\"\",\"ShortChar02\":\"\",\"ShortChar03\":\"\",\"ShortChar04\":\"\",\"ShortChar05\":\"\",\"ShortChar06\":\"\",\"ShortChar07\":\"\",\"ShortChar08\":\"\",\"ShortChar09\":\"\",\"ShortChar10\":\"\",\"SysRowID\":\"72e33225-42c6-495e-b339-b31166769288\",\"RowMod\":\"\"}],\"Client\":[{\"ClientType\":\"EPICOR_REST_CLIENT\",\"ProcessId\":\"\",\"AssemblyName\":\"\",\"CustomizationId\":\"\",\"CurrentUserId\":\"tracyc\",\"CurrentCompany\":\"COMP01\",\"SysRowID\":\"91cca06c-f2cd-4673-9a49-509fdc992a58\"}]}}",
          "Type": 2,
          "Encode": false,
          "ContentType": null
        },
        {
          "Name": "X-API-Key",
          "Value": "v5YSazXmtgABwjSutjM4bRMT06Sf4wsKIxhThafgLLS5P",
          "Type": 2,
          "Encode": false,
          "ContentType": null
        },
        {
          "DataFormat": 3,
          "ContentEncoding": null,
          "Name": "",
          "Value": "{\"Company\":\"COMP01\",\"TranQty\":30,\"ToJobNum\":\"1177333\",\"ToAssemblySeq\":0,\"ToJobSeq\":30,\"pcTranType\":\"STK-MTL\",\"pcMtlQueueRowID\":\"00000000-0000-0000-0000-000000000000\",\"pCallProcess\":\"IssueMaterial\",\"ds\":\"Erp.Tablesets.IssueReturn\"}",
          "Type": 3,
          "Encode": false,
          "ContentType": "application/json"
        }
      ],
      "Files": [],
      "Method": 1,
      "Timeout": 0,
      "Resource": "https://kinetic/KineticTest/api/V1/Erp.BO.IssueReturnSvc/GetNewIssueReturn",
      "RequestFormat": 0,
      "RootElement": null,
      "OnBeforeDeserialization": null,
      "OnBeforeRequest": null,
      "OnAfterRequest": null,
      "Attempts": 1,
      "CompletionOption": 0,
      "ResponseWriter": null,
      "AdvancedResponseWriter": null
    },
    "ContentType": "text/plain",
    "ContentLength": 123,
    "ContentEncoding": [],
    "Content": "Sorry! Something went wrong. Please contact your system administrator. Correlation Id: 0ca94cdc-bb31-4305-b97c-9ce78ccceb1d",
    "StatusCode": 500,
    "IsSuccessStatusCode": false,
    "IsSuccessful": false,
    "StatusDescription": "Internal Server Error",
    "RawBytes": "U29ycnkhIFNvbWV0aGluZyB3ZW50IHdyb25nLiBQbGVhc2UgY29udGFjdCB5b3VyIHN5c3RlbSBhZG1pbmlzdHJhdG9yLiBDb3JyZWxhdGlvbiBJZDogMGNhOTRjZGMtYmIzMS00MzA1LWI5N2MtOWNlNzhjY2NlYjFk",
    "ResponseUri": "https://kinetic/KineticTest/api/V1/Erp.BO.IssueReturnSvc/GetNewIssueReturn",
    "Server": "",
    "Cookies": [],
    "Headers": [
      {
        "Name": "Pragma",
        "Value": "no-cache",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Transfer-Encoding",
        "Value": "chunked",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Telemetry",
        "Value": "{\"TelemetryKey\":\"bc19332c-15b1-48a7-b777-6e31dbc2823f\",\"Telemetry\":true}",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "CallInfo",
        "Value": "{\"CorrelationId\":\"0ca94cdc-bb31-4305-b97c-9ce78ccceb1d\"}",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Cache-Control",
        "Value": "no-store, no-cache",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Date",
        "Value": "Wed, 06 Mar 2024 10:08:14 GMT",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      }
    ],
    "ContentHeaders": [
      {
        "Name": "Content-Type",
        "Value": "text/plain",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Expires",
        "Value": "-1",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      },
      {
        "Name": "Content-Length",
        "Value": "123",
        "Type": 2,
        "Encode": false,
        "ContentType": null
      }
    ],
    "ResponseStatus": 2,
    "ErrorMessage": null,
    "ErrorException": {
      "ClassName": "System.Net.Http.HttpRequestException",
      "Message": "Request failed with status code InternalServerError",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146233088,
      "Source": null,
      "WatsonBuckets": null,
      "SafeSerializationManager": {
        "m_serializedStates": [
          {}
        ]
      },
      "CLR_SafeSerializationManager_RealType": "System.Net.Http.HttpRequestException, System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    },
    "Version": {
      "Major": 1,
      "Minor": 1,
      "Build": -1,
      "Revision": -1,
      "MajorRevision": -1,
      "MinorRevision": -1
    },
    "RootElement": null
  },
  "ResponseData": null,
  "ResponseBody": "Sorry! Something went wrong. Please contact your system administrator. Correlation Id: 0ca94cdc-bb31-4305-b97c-9ce78ccceb1d",
  "BLException": null,
  "BadRequest": null,
  "ResponseStatus": 500,
  "RestCallException": {
    "ClassName": "Newtonsoft.Json.JsonReaderException",
    "Message": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.",
    "Data": null,
    "InnerException": null,
    "HelpURL": null,
    "StackTraceString": "   at Newtonsoft.Json.JsonTextReader.ParseValue()\r\n   at Newtonsoft.Json.JsonTextReader.Read()\r\n   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\r\n   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\r\n   at EpicorRestAPI.EpicorRest.GetEpicorResponseObject(Uri baseUri, RestResponse response)",
    "RemoteStackTraceString": null,
    "RemoteStackIndex": 0,
    "ExceptionMethod": "8\nParseValue\nNewtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed\nNewtonsoft.Json.JsonTextReader\nBoolean ParseValue()",
    "HResult": -2146233088,
    "Source": "Newtonsoft.Json",
    "WatsonBuckets": null
  },
  "RestSharpErrorMessage": null,
  "ResponseError": "Unexpected character encountered while parsing value: S. Path '', line 0, position 0.",
  "IsErrorResponse": true
}

The program ‘[22624] WindowsFormsApp2.exe’ has exited with code 4294967295 (0xffffffff).

Can you post your full code?

Does the call work from Postman with the exact same parameters?

Your Payload is wrong
image

You are sending just the name “Erp.Tablesets.IssueReturn” as your ds parameter.

You need to send in the actual data set. Try Passing in ds as an inline object like this

"ds":"{}"

That will work sometimes (depending on the BO) specially if its a GetNew call

3 Likes

Thanks Jose, do you mean like this: -

This is still giving me an error

No try just

ds = {}
1 Like

I think they are also putting all these values at the top level, when you can see on swagger that they are multiple layers deep:

1 Like

This didn’t work
image

Should the top 5 parameters in my post data be in the ds brackets?

Do I have to feed in every item in the issuereturn dataset?

1 Like

Jose, you do great videos!!
Could you make one for me step by step to do what i need please :rofl:

If you had this working in WCF I would think you don’t need any more fields than you did there. I’m not sure how many are required off the top of my head. You can also figure that out by doing a trace.

new
{
  pcTranType = "STK-MTL",
  pcMtlQueueRowID = "00000000-0000-0000-0000-000000000000",
  pCallProcess = "IssueMaterial",
  ds = new {}
}

This is what is required for that BO. (GetNewIssueReturn)

2 Likes

Ok, that’s good, this is all we fed in using WCF (in fact more in here than in there)

Passing in any other data to that BO is irrelevant, it doesn’t carry through.

Thanks Kevin,
How would I issue material if I can’t pass through the details of the job material and quantity I need to issue?

Ok that statement I made, was intended for the top level fields.

If you pass them in the ds, it might work.

That being said, the purpose of that BO is to get back a perfectly formed ds, that you can manipulate, and then pass to the BO (method) that issues material.

Clear as mud?

1 Like

If the WCF code worked, you will be making the same BO calls but just using REST instead.

1 Like

:see_no_evil:

For example, this payload works:

{
  "pcTranType": "STK-MTL",
  "pcMtlQueueRowID": "00000000-0000-0000-0000-000000000000",
  "pCallProcess": "IssueMaterial",
  "ds": {
              "IssueReturn":
                  [
                      {
                          "Company": "MS1234",
                          "TranQty": 30,
                          "ToJobNum": "1234",
                          "ToAssemblySeq": 10,
                          "ToJobSeq": 10,
                      }
                 ]
  }
}
1 Like

WCF is still an option. It is supported and it is documented.

2 Likes

Still no joy with this yet, my colleague is working on getting WCF enabled but is not having much joy (have enabled it and added business objects but vs project still has errors.
I have referred back to the WCF coding and it does use more methods than just issue material.

This is my original coding, how do I change this to use EpicorRestAPI instead?

private void IssueMaterialToJob(string jobNum, string asmSeq, string mtlSeq, decimal reqQty)
{
try
{

    using (Session epiSession = new Session(epiUid, epiPwd, Session.LicenseType.Default, configFilePath))
    {
        string message = "";
        string partTranPK = "";
        bool outbool;

        IssueReturnImpl irBO = WCFServiceSupport.CreateImpl<Erp.Proxy.BO.IssueReturnImpl>((Ice.Core.Session)epiSession, Erp.Proxy.BO.IssueReturnImpl.UriPath);
        SelectedJobAsmblDataSet selJobAsmDs = new SelectedJobAsmblDataSet();
        IssueReturnDataSet issueReturnDs = new IssueReturnDataSet();

        DataRow dr = selJobAsmDs.SelectedJobAsmbl.NewRow();
        dr["Company"] = "COMP01";
        dr["JobNum"] = jobNum;
        dr["AssemblySeq"] = asmSeq;
        selJobAsmDs.SelectedJobAsmbl.Rows.Add(dr);

        var emptyGuid = new Guid(new Byte[16]);
        issueReturnDs = irBO.GetNewJobAsmblMultiple("STK-MTL", emptyGuid, "IssueMaterial", selJobAsmDs, out message);

        irBO.OnChangingToJobSeq(Int32.Parse(mtlSeq), issueReturnDs);

        issueReturnDs.IssueReturn[issueReturnDs.IssueReturn.Count - 1]["ToJobSeq"] = asmSeq;
        issueReturnDs.IssueReturn[issueReturnDs.IssueReturn.Count - 1]["ToJobSeq"] = mtlSeq;
        issueReturnDs.IssueReturn[issueReturnDs.IssueReturn.Count - 1]["RowMod"] = "U";
        irBO.OnChangeToJobSeq(issueReturnDs, "IssueMaterial", out message);

        irBO.OnChangeTranQty(reqQty, issueReturnDs);
        irBO.PrePerformMaterialMovement(issueReturnDs, out outbool);
        irBO.MasterInventoryBinTests(issueReturnDs, out message, out message, out message, out message, out message, out message);
        irBO.PerformMaterialMovement(false, issueReturnDs, out message, out partTranPK);
    }
}
catch (Exception ex)
{
    MethodBase m = MethodBase.GetCurrentMethod();
    LogException(m.Name, jobNum + ": " + ex.ToString());
}

Every single BO call you are making via WCF you will still have to make, just doing it via REST. The structure of commands is exactly the same, just the means of communicating it to the server is different.

So

irBO.PerformMaterialMovement …

turns into

EpicorRest.BoPost(“Erp.BO.IssueReturnSvc”, “PerformMaterialMovement” …

And so on.

You have located the help page for the IssueReturn endpoint right?