我正在尝试将以下cUrl命令转换为Restsharp。
curl --request POST \
--url 'https://api.forte.net/v3/organizations/org_{{organizationID}}/customers/' \
--header 'Authorization: {{Authorization}}' \
--header 'Content-Type: application/json' \
--header 'X-Forte-Auth-Organization-Id: org_{{AuthOrganizationID}}' \
--data '{
"first_name": "Emmett",
"last_name": "Brown",
"company_name": "Brown Associates",
"customer_id": "025897",
"location_id": "loc_192642"
}'
这是我到目前为止所做的。我根本不确定如何做到这一点,这是迄今为止我能够翻译的内容。
public string getAddressToken(string street, string city, string state, string zip)
{
Physical_Address address = new Physical_Address
{
street_line1 = street,
locality = city,
region = state,
postal_code = zip
};
var client = new RestClient(url);
// client.Authenticator = new HttpBasicAuthenticator(MerchantLoginId, ApiTransactionKey);
var request = new RestRequest();
//create a authorization header using basic Authentication
string credentials = Convert.ToBase64String(Encoding.Default.GetBytes(MerchantLoginId + ":" + ApiTransactionKey)).Trim();
request.AddHeader("Authorization", credentials);
request.AddHeader("Accept", accept);
//add organization
request.AddHeader("X-Forte-Auth-Organization-Id", "org_"+organization);
request.AddBody(address);
request.AddBody("/addresses");
IRestResponse response = client.Execute(request);
var content = response.Content;
return content;
}