2

I am currently playing around with some things...According to this link, I need to construct a route that is open to the following format

webServiceURL/version/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier?passesUpdatedSince=tag

so I defined the route like so

 config.Routes.MapHttpRoute( name: "DefaultApi3", routeTemplate: "{version}/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}/{passesUpdatedSince}", defaults: new { controller = "SerialNumbers", action = "GET", passesUpdatedSince = RouteParameter.Optional } ); 

However, the following route fails for the url

http://localhost/v1/devices/24358235235loji200/registrations/pass.com.mypass?passesUpdatedSince=12a512

How can I configure the route so that the above url can reach my controller?

My controller looks like

[HttpGet] public HttpResponseMessage Get(string passesUpdatedSince ="") { //do stuff } 

UPDATE

Thanks to the comments, I've made the following changes.

the route

config.Routes.MapHttpRoute( name: "DefaultApi3", routeTemplate: "v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}", defaults: new { controller = "SerialNumbers", action = "GET" } ); 

My controller is as follows

public HttpResponseMessage Get(string deviceLibraryIdentifier, string passTypeIdentifier, string passesUpdatedSince = "") { //do stuff } 

According to the Apple docs, is it right to assume the following the webservice calls could look like

http://localhost:31472/v1/devices/23lk5235232oijlk/registrations/pass.com.mypass http://localhost:31472/v1/devices/23lk5235232oijlk/registrations/pass.com.mypass?passesUpdatedSince=159025

as these are returning 404.

These, however, do work. http://localhost:31472/v1/devices/23lk5235232oijlk/registrations/pass.com.mypass/?passesUpdatedSince=1415l http://localhost:31472/v1/devices/23lk5235232oijlk/registrations/pass.com.mypass/

So would there be a way to get it to work without the presence of the / near the end of the url?

It does look like the device is unable to recognize the route. I get the following message

Get serial #s task (for device 2523ff2fswtsfdh6544, pass type pass.com.mypass, last updated (null); with web service url https://weburl) encountered error: Unexpected response code 404

3
  • 1
    Shouldn't the URL be http://localhost/v1/devices/24358235235loji200/registrations/pass.com.mypass/12a512? Commented May 27, 2015 at 16:37
  • 1
    @DavidG is correct. Query string parameters (after the ?) will go along for the ride; your route only needs to specify what will be passed along in url segments. Commented May 27, 2015 at 16:40
  • the URL that Apple sends would be in that format. I can't control it so I have to conform a route to it. Having a / and omitting the passesUpdatedSince would make it work on my end, but it's not the exact route Apple would send. Unless I'm misinterpreting the apple docs? Commented May 27, 2015 at 16:45

2 Answers 2

1

Because part of the URI had periods in it (pass.com.mypass), this always returned a 404

I had to add the

<modules runAllManagedModulesForAllRequests="true" /> 

in my web.config. And after that, everything worked as expected

Sign up to request clarification or add additional context in comments.

1 Comment

This worked for me! How did you figure this out? I implemented in an Asp.Net Web API 2 Project, so my routes were a little different. For those that don't know, here is more information on what this does and how to add it. learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/… Also, I would not hardcode the version since that appears to be coming from Apple Wallet. Use {version} instead. Thanks!
0

For the route, try:

config.Routes.MapHttpRoute( name: "DefaultApi3", routeTemplate: "{version}/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}", defaults: new { controller = "SerialNumbers", action = "GET" } ); 

Note that you should actually have a hard-coded value where {version} is, according to the link you gave us (https://developer.apple.com/library/ios/documentation/PassKit/Reference/PassKit_WebService/WebService.html#//apple_ref/doc/uid/TP40011988-CH0-SW4).

A hard-coded version would look like this:

config.Routes.MapHttpRoute( name: "DefaultApi3", routeTemplate: "v1/devices/{deviceLibraryIdentifier}/registrations/{passTypeIdentifier}", defaults: new { controller = "SerialNumbers", action = "GET" } ); 

Your controller action also needs to be able to accept all parameters of the route:

[HttpGet] public HttpResponseMessage Get(string deviceLibraryIdentifier, string passTypeIdentifier, string passesUpdatedSince ="") { //do stuff } 

5 Comments

Sorry, can't seem to get that one to work with that url
Try removing the / at the end of routeTemplate. Coz you need the URL to end with {passTypeIdentifier}?passesUpdatedSince=tag instead of {passTypeIdentifier}/?passesUpdatedSince=tag.
@prawn, note that if you are treating the version as a parameter in your route, the controller action will need that as a parameter, as well.
Thank you for the edit. Getting closer but it's still problematic when the url is ending in {passTypeIdentifier}?passesUpdatedSince=tag
@prawn, please edit your question to include the new code that you have tried. Please also keep your original question so people can see where you started vs. where you are now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.