Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To develop interface from VFP to WS but not know how
Message
De
09/10/2020 11:41:07
 
 
À
09/10/2020 05:42:21
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Divers
Thread ID:
01676523
Message ID:
01676558
Vues:
32
>>Good afternoon to all. I have to develop an interface (prefently COM dll) in VFP to a partner's WS (Web Service). This interface has to send data generated by our applications (customs duties) to a WS in Json format and this WS has to respond if it's okay with a small json string.
>>
>>They gave me info and instructions on which I have to base my development.
>>
>>Below is the info:
>>
>>Description
>>Insert customs - This endpoint creates a new manifest.
>>
>>URL
>>TEST https://api-test.mypartner.com/
>>
>>Endpoint
>>POST /wcf-services/service-customs.svc/customs/insert_customs_data
>>
>>
>>The json string is like this (sensitive data was changed):
>>
>>{
>>  "user_info": {
>>    "user_code": 1,
>>    "user_key": "ok",
>>    "app_key": "ok"
>>  },
>>  "customs_header": {
>>    "pch_reference": "Document Reference",
>>    "country_iso_code": "CL",
>>    "pch_charged_datetime": "/Date(1579669200000-0500)/",
>>    "pch_items": [
>>      {
>>        "trck_nmr_fol": 12345678,
>>        "consignee_id": "1234567890",
>>        "is_additional": false,
>>        "pcc_charges": [
>>          {
>>            "pcc_charge_value": 18.80,
>>            "pcc_charge_code": 1,
>>            "pcc_comment": "Comment for this charge"
>>          }
>>        ]
>>      }
>>    ]
>>  }
>>}
>>
>>
>>I guess I have advanced a little with this:
>>
>>
>>loHTTP= CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")
>>loHTTP.Open("POST", "https://api-test.mypartner.com/", .F.)
>>loHTTP.Setrequestheader("Content-type", "application/x-www-form-urlencoded")
>>loHTTP.Send("json=" + m.lcJsonString)
>>
>>
>>It returns me an html string which says:
>>
>>Server error
>>405 - HTTP verb used to access this page is not allowed.
>
>Try with get instead of post. Also, try to add the "json=..." part to the url, as a parameter, urlencoded - as you announced when you asked for the header.


The code that I showed. Was almost a copy/paste (except for the urls and data) code that I used in another interface I developed some months ago and is still working flawlessly, thanks to Antonio Lopes.

I'll tried your suggestion. But yet I can't send the json. I used POST because in the documentation (which I showed in my first post) at the "Endpoint" description, it says:

POST /wcf-services/service-customs.svc/customs/insert_customs_data

Altought is not referring to the main URL but a path. I tried to POST to /wcf-services/service-customs.svc/customs/insert_customs_data but VFP gave me an error.

It looks like it's something simple but I can't imagine it.

Thanks anyway.


Thanks any way.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform