Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing HTTP Headers in XML

I have to code this HTTP Request to Yelp API in XML

    GET /v2/business/yelp-san-francisco HTTP/1.1
Host: api.yelp.com
Authorization: OAuth realm="",oauth_consumer_key="xxxxxxxxxxxxxxxx",oauth_token="xxxxxxxxxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1402918725",oauth_nonce="vCTAQl",oauth_version="1.0",oauth_signature="xxxxxxxxxxxxxxxx"
Cache-Control: no-cache
Postman-Token: 338ad760-49be-df0b-a4ba-3eaa12586cd1

How can I implement it in XML? I have tried like this:

<property name="yelp.apiUri" value="http://api.yelp.com/v2/" />
    <property name="yelp.oauth.consumerKey" expression="$func:consumerKey" />
    <property name="yelp.oauth.consumerKeySecret" expression="$func:consumerKeySecret" />
    <property name="yelp.oauth.accessToken" expression="$func:accessToken" />
    <property name="yelp.oauth.accessTokenSecret" expression="$func:accessTokenSecret" />

    <property name="yelp.oauth.nonce" value="dummynonce"/>
    <property name="yelp.oauth.timestamp" value="dummytimestamp"/>

    <property name="Authentication" expression="fn:concat(
    'OAuth realm=',
    'oauth_consumer_key=', get-property('yelp.oauth.consumerKey'),
    'oauth_token=', get-property('yelp.oauth.accessToken'),
    'oauth_signature_method=HMAC-SHA1',
    'oauth_timestamp=', get-property('yelp.oauth.timestamp'),
    'oauth_nonce=', get-property('yelp.oauth.nonce'),
    'oauth_version=1.0',
    'oauth_signature=', get-property('yelp.oauth.accessTokenSecret')
    )"/>

But it didn't work.


1 Answers

Error in your header tag.Replace the property tag as header tag and change your code like this:

    <header name="Authorization" expression="fn:concat(
    'OAuth realm=&quot;&quot;',
    ',oauth_consumer_key=&quot;',get-property('yelp.oauth.consumerKey'),'&quot;',
    ',oauth_token=&quot;',get-property('yelp.oauth.accessToken'),'&quot;',
    ',oauth_signature_method=&quot;HMAC-SHA1&quot;',
    ',oauth_timestamp=&quot;',get-property('yelp.oauth.timestamp'),'&quot;',
    ',oauth_nonce=&quot;',get-property('yelp.oauth.nonce'),'&quot;',
    ',oauth_version=&quot;1.0&quot;',
    ',oauth_signature=&quot;', get-property('yelp.oauth.signature'),'&quot;'
    )" scope="transport" />
like image 167
Jarachanthan Ratnakumar Avatar answered Aug 09 '26 01:08

Jarachanthan Ratnakumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!