RestAPI Response Code Error

Hi, i am trying to integrate Epicor and FEDEX API, it was going quite well until i had to define the Json reponse for creating a shipment in a code block.

I currently have the definition code. but all i can return is definitioncc does not exist in this context.
I believe it is to do with the arrays but i have gotten lost and i am struggling with it.

{

var definitioncc = new {
transactionId = “”,
output = new {
transactionShipments = new [] { new {
masterTrackingNumber = “”,
serviceType = “”,
shipDatestamp = “”,
serviceName = “”,
pieceResponse = new [] { new {
masterTrackingNumber = “”,
trackingNumber = “”,
additionalChargesDiscount = 0.0,
netRateAmount = 0.0,
netChargeAmount = 0.0,
netDiscountAmount = 0.0,
packageDocuments = new [] { new {
contentType = “”,
copiesToPrint = 0,
encodedLabel = “”,
docType = “”
} },
customerReferences = new [] {""},
codcollectionAmount = 0.0,
baseRateAmount = 0.0
} },
completedShipmentDetail = new {
usDomestic = false,
carrierCode = “”,
masterTrackingId = new {
trackingIdType = “”,
formId = “”,
trackingNumber = “”
},
serviceDescription = new {
serviceId = “”,
serviceType = “”,
code = “”,
names = new [] { new {
type = “”,
encoding = “”,
value = “”
} },

                                                                        operatingOrgCodes = new [] {""},
                                                                        serviceCategory = "",
                                                                        description = "",
                                                                        astraDescription = ""
                                                                        },
                                                      packagingDescription = "",
                                                      operationalDetail = new {
                                                                        ursaPrefixCode = "",
                                                                        ursaSuffixCode = "",
                                                                        originLocationId = "",
                                                                        originLocationNumber = 0,
                                                                        originServiceArea = "",
                                                                        destinationLocationId = "",
                                                                        destinationLocationNumber = "",
                                                                        destinationServiceArea = "",
                                                                        destinationLocationStateOrProvinceCode = "",
                                                                        deliveryDate = "",
                                                                        deliveryDay = "",
                                                                        commitDate = "",
                                                                        commitDay = "",
                                                                        ineligbleForMoneyBackGuarantee = false,
                                                                        astraPlannedServiceLevel = "",
                                                                        astraDescription = "",
                                                                        postalCode = "",
                                                                        stateOrProvinceCode = "",
                                                                        countryCode = "",
                                                                        airportId = "",
                                                                        serviceCode = "",
                                                                        packagingCode = "",
                                                                        publishedDeliveryTime = "",
                                                                        scac = ""
                                                                        },
                                                      completedPackageDetails = new [] { new {
                                                                        sequenceNumber = 1,
                                                                        trackingIds = new [] { new {
                                                                                          trackingIdType = "",
                                                                                          formId = "",
                                                                                          trackingNumber = "",
                                                                                          } },
                                                                        groupNumber = 0,
                                                                        signatureOption = "",
                                                                        operationalDetails = new {
                                                                                          barcodes = new {
                                                                                                      binaryBarcodes = new [] { new {
                                                                                                                      type = "",
                                                                                                                      value = ""
                                                                                                                      } },
                                                                                                      stringBarcodes = new [] { new {
                                                                                                                      type = "",
                                                                                                                      value = ""
                                                                                                                      } }
                                                                                                      },                
                                                                                          astraHandlingText = "",
                                                                                          operationalInstructions = new [] { new {
                                                                                                      number = 0,
                                                                                                      content = ""
                                                                                                      }
                                                                                                  
                                                                                           } }
                                                                        } },
                                                       documentRequirements = new {
                                                                      prohibitedDocuments = new [] {"", ""}
                                                                        } },
                  serviceCategory = ""

} }

} };

};

Here’s a lazy way to create JSONs. Alternatively, you can create classes and use those instead of JObject and JArray

    // define call object
    objTCall = new Newtonsoft.Json.Linq.JObject();
    
    // call object fields
    objTCall.interfaceId = rpInterfaceID;
    objTCall.syncValidate = true;
    
    // define orders array
    objOrderArray = new Newtonsoft.Json.Linq.JArray();
    
    // order 
    objOrder = new Newtonsoft.Json.Linq.JObject();
    objOrder.salesOrderRef = tSONo;
    objOrder.consigneeRef = eSONo.ToString(); // our SO No
    objOrder.status = "NEW";

    // add order to array
    objOrderArray.Add(objOrder);

    // set orders
    objTCall.orders = objOrderArray;

    // serialize for rest call
    string sbdy = Newtonsoft.Json.JsonConvert.SerializeObject(objTCall);
1 Like