EDI API consuming in C# application
Hi,
As per my requirement I have to pass JSON text to EDI API to get the EDI File/string. I wrote code like below but always I am getting Bad request Invalid content-type. Could you please guide me where I am doing mistake.
var client = new RestClient("https://api.edination.com/v2/x12/write");
client.Timeout = -1;
// HTTP Type
var request = new RestRequest(Method.POST);
string jsonString= "[{'SegmentDelimiter': '~','DataElementDelimiter': '*','ISA': {'AuthorizationInformationQualifier_1': '00','AuthorizationInformation_2': ' ','SecurityInformationQualifier_3': '00','SecurityInformation_4': ' ','SenderIDQualifier_5': 'ZZ','InterchangeSenderID_6': '378778353P ','ReceiverIDQualifier_7': 'ZZ','InterchangeReceiverID_8': '264595216 ','InterchangeDate_9': '220616','InterchangeTime_10': '1132','InterchangeControlStandardsIdentifier_11': '^','InterchangeControlVersionNumber_12': '00501','InterchangeControlNumber_13': '000386762','AcknowledgementRequested_14': '1','UsageIndicator_15': 'P','ComponentElementSeparator_16': ':'},'Groups': [{'GS': {'CodeIdentifyingInformationType_1': 'HC','SenderIDCode_2': '378778353P','ReceiverIDCode_3': '264595216','Date_4': '220616','Time_5': '1132','GroupControlNumber_6': '386762','TransactionTypeCode_7': 'X','VersionAndRelease_8': '005010X224A2'},'Transactions': [{'ST': {'TransactionSetIdentifierCode_01': '837','TransactionSetControlNumber_02': '000000001','ImplementationConventionPreference_03': '005010X224A2'},'BHT_BeginningOfHierarchicalTransaction': {'HierarchicalStructureCode_01': '0019','TransactionSetPurposeCode_02': '00','SubmitterTransactionIdentifier_03': '502167313_672681660','TransactionSetCreationDate_04': '20140812','TransactionSetCreationTime_05': '0000','TransactionTypeCode_06': 'CH'},'AllNM1': {'Loop1000A': {'NM1_SubmitterName': {'EntityIdentifierCode_01': '41','EntityTypeQualifier_02': '2','ResponseContactLastorOrganizationName_03': 'File Load Generator','IdentificationCodeQualifier_08': '46','ResponseContactIdentifier_09': '453358287'},'PER_SubmitterEDIContactInformation': [{'ContactFunctionCode_01': 'IC','ResponseContactName_02': 'File Load Generator Nicholas Raverty','CommunicationNumberQualifier_03': 'EM','ResponseContactCommunicationNumber_04': 'Communication Number EM Type','CommunicationNumberQualifier_05': 'TE','ResponseContactCommunicationNumber_06': '8009336593'}]},'Loop1000B': {'NM1_ReceiverName': {'EntityIdentifierCode_01': '40','EntityTypeQualifier_02': '2','ResponseContactLastorOrganizationName_03': 'File Receiver Organization','IdentificationCodeQualifier_08': '46','ResponseContactIdentifier_09': '264595216'}}},'Loop2000A': [{'HL_BillingProviderHierarchicalLevel': {'HierarchicalIDNumber_01': '1','HierarchicalLevelCode_03': '20','HierarchicalChildCode_04': '1'},'AllNM1': {'Loop2010AA': {'NM1_BillingProviderName': {'EntityIdentifierCode_01': '85','EntityTypeQualifier_02': '2','ResponseContactLastorOrganizationName_03': 'MISKIEWICZ DDS','IdentificationCodeQualifier_08': 'XX','ResponseContactIdentifier_09': '1708427939'},'N3_BillingProviderAddress': {'ResponseContactAddressLine_01': '1605 CAPTAIN MARBURY AVE'},'N4_BillingProviderCity_State_ZIPCode': {'AdditionalPatientInformationContactCityName_01': 'COLUMBIA','AdditionalPatientInformationContactStateCode_02': 'SC','AdditionalPatientInformationContactPostalZoneorZIPCode_03': '292900000'},'AllREF': {'REF_BillingProviderTaxIdentification': {'ReferenceIdentificationQualifier_01': 'EI','MemberGrouporPolicyNumber_02': '059686201'}}}},'Loop2000B': [{'HL_SubscriberHierarchicalLevel': {'HierarchicalIDNumber_01': '2','HierarchicalParentIDNumber_02': '1','HierarchicalLevelCode_03': '22','HierarchicalChildCode_04': '0'},'SBR_SubscriberInformation': {'PayerResponsibilitySequenceNumberCode_01': 'S','IndividualRelationshipCode_02': '18', 'ClaimFilingIndicatorCode_09': 'MC'},'AllNM1': {'Loop2010BA': {'NM1_SubscriberName': {'EntityIdentifierCode_01': 'IL','EntityTypeQualifier_02': '1','ResponseContactLastorOrganizationName_03': 'LAST_247759','ResponseContactFirstName_04': 'FIRST_247759','IdentificationCodeQualifier_08': 'MI','ResponseContactIdentifier_09': '247759W7'},'N3_SubscriberAddress': {'ResponseContactAddressLine_01': 'ENROLLEE_ADDRESS_247759'},'N4_SubscriberCity_State_ZIPCode': {'AdditionalPatientInformationContactCityName_01': 'COATESVILLE','AdditionalPatientInformationContactStateCode_02': 'PA','AdditionalPatientInformationContactPostalZoneorZIPCode_03': '193200000'},'DMG_SubscriberDemographicInformation': {'DateTimePeriodFormatQualifier_01': 'D8','DependentBirthDate_02': '19990714','DependentGenderCode_03': 'M'}},'Loop2010BB': {'NM1_PayerName': {'EntityIdentifierCode_01': 'PR','EntityTypeQualifier_02': '2','ResponseContactLastorOrganizationName_03': 'INSURER_2','IdentificationCodeQualifier_08': 'PI','ResponseContactIdentifier_09': '2'}}},'Loop2300': [{'CLM_ClaimInformation': {'PatientControlNumber_01': '935205','TotalClaimChargeAmount_02': '247','HealthCareServiceLocationInformation_05': {'FacilityTypeCode_01': '11','FacilityCodeQualifier_02': 'B','ClaimFrequencyTypeCode_03': '1'},'ProviderorSupplierSignatureIndicator_06': 'Y','AssignmentorPlanParticipationCode_07': 'A','BenefitsAssignmentCertificationIndicator_08': 'Y','ReleaseofInformationCode_09': 'Y'},'AllDTP': {'DTP_Date_ServiceDate': {'DateTimeQualifier_01': '472','DateTimePeriodFormatQualifier_02': 'D8','DateTimePeriod_03': '20220616'}},'AllREF': {'REF_ClaimIdentifierForTransmissionIntermediaries': {'ReferenceIdentificationQualifier_01': 'D9','MemberGrouporPolicyNumber_02': '17676372816'}},'AllNM1': {'Loop2310B': {'NM1_RenderingProviderName': {'EntityIdentifierCode_01': '82','EntityTypeQualifier_02': '1','ResponseContactLastorOrganizationName_03': 'MERCURIO','ResponseContactFirstName_04': 'RHEBA','ResponseContactMiddleName_05': 'ANGEL','IdentificationCodeQualifier_08': 'XX', 'ResponseContactIdentifier_09': '3984914770'},'PRV_RenderingProviderSpecialtyInformation': { 'ProviderCode_01': 'PE','ReferenceIdentificationQualifier_02': 'PXC','ProviderTaxonomyCode_03': '1223D0001X'}},'Loop2310C': {'NM1_ServiceFacilityLocationName': {'EntityIdentifierCode_01': '77','EntityTypeQualifier_02': '2','ResponseContactLastorOrganizationName_03': 'DINAN DENTAL CARE','IdentificationCodeQualifier_08': 'XX','ResponseContactIdentifier_09': '3091055384'},'N3_ServiceFacilityLocationAddress': {'ResponseContactAddressLine_01': '1605 CAPTAIN MARBURY AVE'},'N4_ServiceFacilityLocationCity_State_ZipCode': {'AdditionalPatientInformationContactCityName_01': 'COLUMBIA','AdditionalPatientInformationContactStateCode_02': 'SC','AdditionalPatientInformationContactPostalZoneorZIPCode_03': '292900000'}}},'Loop2400': [{'LX_ServiceLineNumber': {'AssignedNumber_01': '1'},'SV3_DentalService': {'CompositeMedicalProcedureIdentifier_01': {'ProductorServiceIDQualifier_01': 'AD','ProcedureCode_02': 'D4220'},'LineItemChargeAmount_02': '247','ProcedureCount_06': '1'},'TOO_ToothInformation': [{'CodeListQualifierCode_01': 'JP','ToothCode_02': 'LL'}],'AllDTP': {'DTP_Date_ServiceDate': {'DateTimeQualifier_01': '472','DateTimePeriodFormatQualifier_02': 'D8','DateTimePeriod_03': '20220616'}}}]}]}]}],'SE': {'NumberofIncludedSegments_01': '30','TransactionSetControlNumber_02': '000000001'},'Model': 'EdiNation.X12.HIPAA.005010'}],'GETrailers': [{'NumberOfIncludedSets_1': '1','GroupControlNumber_2': '386762'}]}],'IEATrailers': [{'NumberOfIncludedGroups_1': '1','InterchangeControlNumber_2': '000386762'}],'Result': {'LastIndex': 34,'Details': [],'Status': 'success'}}]";
JArray array = (JArray)JsonConvert.DeserializeObject(jsonString);
// Build the entire Request with body and Header.
request.AddHeader("Ocp-Apim-Subscription-Key", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
request.AddHeader("Content-Length", "248");
request.RequestFormat = DataFormat.Json;
//request.AddHeader("Content-Type", "application/octet-stream");
request.AddJsonBody(array.ToString(), "application/json");
IRestResponse restresponse = client.Execute(request);
Comments
1 comment
Hello,
As you can see in the API reference, the x12/write endpoint expects an X12Interchange object. It looks like you are passing an array of X12Interchanges. Remove the square brackets from your JSON and try again.
Please sign in to leave a comment.