I am interacting with an API that sometimes will return a reference number for certain functions. How would i go about displaying this reference number. At present the API returns for example this string (some code taken out for security reasons).
if (AppSettings.GetLandingPageReceipts())
{
long returnValue = loanLP.AddWithdrawalToBankID(CustomerID, SavingsAccountID, BankAccID, Amount);
return string.Concat("Requested Withdrawal Ref No: ", returnValue);
}
ReceiptWithdrawal withdraw = new ReceiptWithdrawal(CustomerID, SavingsAccountID, Amount, session, pp, BankAccID);
ReceiptTRN TRN = new ReceiptTRN();
TRN.Post(withdraw);
return JsonConvert.SerializeObject(withdraw.ReceiptNo);
In the Ruby code I use this for Post calls
def post_call(routePath, params)
started_at = Time.now
logger.bench 'SERVICE - POST', started_at, routePath
uri = URI.parse("#{settings.abacus_service_endpoint}#{routePath}")
http = Net::HTTP.new(uri.host, uri.port)
http.set_debug_output $stderr
req = Net::HTTP::Post.new(uri.request_uri,get_header_for_abacus_service)
req.form_data = params
resp = http.request(req)
if response_ok?(resp)
if @errors
puts '======= post request form_data ======='
puts params
puts '==================='
end
return resp
end
end
I can see the following in my console when working locally so I know its being passed. Its just accessing it is the problem.
opening connection to 10.10.10.27...
opened
<- "POST /Accounts/WithdrawalToBank HTTP/1.1\r\nAuthorization: Token 433\r\nX-Customer-Id: 433\r\nX-Customer-Pin: 8EFD155E7C829421E16F14D367568C4179C4548320CD7E1B6AD6E9A485F2AF092FA42D0F645085F3DBBA5AEC2434720FC76E407E41443C3F5EDAFB958793254A\r\nX-Ip-Address: 10.0.2.2\r\nAccept: */*\r\nUser-Agent: Ruby\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nHost: 10.10.10.27:3579\r\nContent-Length: 81\r\n\r\n"
<- "CustomerID=433&SavingsAccountID=10922&BankAccountID=2450&Amount=10.00&Reference=a"
-> "HTTP/1.1 200 OK\r\n"
-> "Transfer-Encoding: chunked\r\n"
-> "Content-Type: text/html\r\n"
-> "Server: Microsoft-HTTPAPI/2.0\r\n"
-> "Date: Mon, 23 Nov 2015 11:03:02 GMT\r\n"
-> "Connection: close\r\n"
-> "\r\n"
-> "22\r\n"
reading 34 bytes...
-> "Requested Withdrawal Ref No: 10059"
read 34 bytes
reading 2 bytes...
-> "\r\n"
read 2 bytes
-> "0\r\n"
-> "\r\n"
Conn close
If any further information is needed please let me know.
如果API返回的是正文,您应该可以通过resp.body
从响应中resp.body
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.