api - Converting curl command to C# code -
i having problems converting curl command c# code.
i have been given curl command includes api key follows:
curl -k -u x:459c4da6401d39bbf9327ee17175e25c -h "content-type: application/json" https://disney.com/v1/services.json when watch call in fiddler can see header value looks this:
authorization: basic edo0ntljngrhnjqwmwqzowjizjkzmjdlzte3mtc1zti1yw== so, curl command working perfectly... cannot replicate in c# code
i don't understand how x:459c4da6401d39bbf9327ee17175e25c has changed authorization: basic edo0ntljngrhnjqwmwqzowjizjkzmjdlzte3mtc1zti1yw==
and subsequently, confused how c# code change api key seeing in fiddler.
when use code add header authorisation fails:
httpwebrequest.headers.add("authorization", "459c4da6401d39bbf9327ee17175e25c"); i have tried:
httpwebrequest.headers["authorization"] = "basic " + convert.tobase64string(encoding.ascii.getbytes("459c4da6401d39bbf9327ee17175e25c")); but produces header value of this:
authorization: basic ndu5yzrkyty0mdfkmzliymy5mzi3zwuxnze3nwuynwm= can please?
thanks
edo0ntljngrhnjqwmwqzowjizjkzmjdlzte3mtc1zti1yw== base64 encode of x:459c4da6401d39bbf9327ee17175e25c. try online here.
and request header authorization base64 string encoded above.
httpwebrequest.headers.add("authorization", "basic edo0ntljngrhnjqwmwqzowjizjkzmjdlzte3mtc1zti1yw=="); you can use this link perform base64 encoding/decoding in c#.
Comments
Post a Comment