Apply With LinkedIn Button: REST Web Service in WCF (C#)

10 posts / 0 new
Last post
Joined: 07/28/2011
Fri, 09/16/2011 - 04:20
Apply With LinkedIn Button: REST Web Service in WCF (C#)

Hi,

I am trying to create a WCF REST Web Service (C#) to receive the Http Post feed from the ApplyWithLinkedIn button. Currently I am not receiving any request from LinkedIn when the button is clicked, but cannot determine why. When I call into my web service from Fiddler using an http post request, my webservice is called and correctly dumps the input stream to file.

I receive the email successfully when using data-email attribute, so I am pretty sure that the javascript on my recruitment site is correct.

<script type="IN/Apply"
data-companyId="XXXXX"
data-jobTitle="UX Architect"
data-onclick="myOnclickFunction"
data-onsuccess="myOnsuccessFunction"
data-url="http://dummyurl.cloudapp.net/ApplyWithLinkedIn.svc/LinkedInApplication">
</script>

The ApplyWithLinkedIn button is on a different domain to my web service, but would not expect this to be an issue.

Please can anyone help with this.

Joined: 07/28/2011
Fri, 09/16/2011 - 06:14

OK, I now have my service working, albeit partially. I would like to use the data-urlFormat option to send my data as xml, but when I do this I get no data into my service. When omitting the data-urlFormat attribute, I do get the feed into my web service in Json format.

I am able to extract the feed using this syntax:
OperationContext.Current.RequestContext.RequestMessage.ToString()

BTW: Are there any examples on your site of using the ApplyWithLinkedIn API with WCF services???

Joined: 07/28/2011
Fri, 09/16/2011 - 06:50

I'm getting there, slowly. Please look at the sample xml output on the following page... https://developer.linkedin.com/application-response-data-structure. The schema shows an <id> tag within the <job> tag. However, when I get a feed from LinkedIn, the <id> tag is in the <company> tag instead. This may be partly the reason why my xml feed was not being correctly deserialized into the objects within WCF. Does the schema change very often??? I need to know so I can determine whether to work to check whether the data conforms to an xsd (preferable) or simply to use the input stream to find the elements of data that I need.

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Fri, 09/16/2011 - 14:17

Hi David!

Glad you were able to find solutions to your earlier inquiries! As to your latest one, the schema will rarely change and when it does, it should be adding new fields, not changing existing ones unless we communicate it in advance. As to your issue with the ID field, are you saying the Job ID you provided is showing up nested under company, or you are just finding a field named ID in company (which could be the company ID)?

-Jeremy

Joined: 07/28/2011
Mon, 09/19/2011 - 01:58

Hi Jeremy,

Thanks for the reply. With regards the ID field, maybe it's my misunderstanding, but the response from ApplyWithLinkedIn had an Id element within the company element (presumably the companyId), and no Id with the job tag (presumably the jobId). But the xml sample file had the reverse! I treated the xml sample file as an xsd, and probably should not have. I guess the answer is that there can be a company/Id and a job/Id?

Thanks..

Joined: 07/28/2011
Mon, 09/19/2011 - 02:04

here is a snippet of the xml from https://developer.linkedin.com/application-response-data-structure...
<job>
<id>1337</id>
<company>
<name>LinkedIn</name>
</company>
<position>
<title>Developer Advocate</title>
</position>
</job>

here is a snippet of the xml from ApplyWithLinkedIn feed...
<job>
<company>
<id>21995</id>
<name>MyCompanyName</name>
</company>
<position>
<title>UX Architect/Designer</title>
</position>
<location-description>Los Angeles</location-description>
</job>

Eugene O&#039;Neill's picture
Developer Advocate
Joined: 01/07/2011
Mon, 09/19/2011 - 14:39

The schema should be something like:
<job>
  <id>1234</id>
  <company>
    <id>1337</id>
    <name>LinkedIn</name>
  </company>
...
</job>

Where 1234 is from data-jobId and 1337 is from data-companyId: e.g.
<script type="IN/Apply" data-companyId="1337" data-jobId="1234" ...></script>

Joined: 07/28/2011
Wed, 09/21/2011 - 03:29

Great thanks for the info.

Bishnubrata Panigrahi's picture
Joined: 03/16/2011
Tue, 02/21/2012 - 02:36

Hi David,

I am at the square one of this issue.
I also have the similar requirement of getting the response as XML and store it in data base.

I am unable to getting the HTTP response back to my page.(either as JSON or as XML)

Can you please suggest any thoughts on this...

Thanks,
Bishnu.

Jeremy Johnstone's picture
Developer Advocate
Joined: 04/17/2011
Tue, 02/21/2012 - 19:22

Hi Bishnu,

There are many methods of doing this, but they all depend on your environment and what works best for your site. Have you read the documentation already?

-Jeremy