Django throwing "Incorrect type. Expected URL string" on API call
<p>I can't work out why Django REST framework is complaining it is expecting a string when it should be expecting an int! The error I am getting is:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>{"_body":"{\"who_saw\":[\"Incorrect type. Expected URL string, received int.\"],\"item_seen\":[\"Incorrect type. Expected URL string, received int.\"]}","status":400,"statusText":"Ok","headers":{"Content-Type":["application/json;q=0.8"]},"type":2,"url":"http://127.0.0.1:8000/api/seen/"}</code></pre>
</div>
</div>
</p>

<p>I am using the following Angular 2 http code to make a POST request from an app to a Django REST Framework server:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>    let body = JSON.stringify({ item_seen: 1, who_saw: 2, liked: 0 });

    let headers = new Headers();
    headers.append('Content-Type', 'application/json');

    this.http.post('http://127.0.0.1:8000/api/seen/',
        body, {
          headers: headers
        })
        .map(res =&gt; res.json())
        .subscribe(
            data =&gt; {
              alert('DATA: '+JSON.stringify(data));
            },
            err =&gt; {
              alert('ERROR: '+JSON.stringify(err));
            },
            () =&gt; {
              alert('Complete');
            }
        );</code></pre>
</div>
</div>
</p>

<p>My model is:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>class Seen(models.Model):
    item_seen           = models.ForeignKey(Item, on_delete=models.CASCADE)     # id of the item that has been seen
    who_saw             = models.ForeignKey(User, on_delete=models.CASCADE)     # id of user who viewed it
    date_seen           = models.DateTimeField(auto_now_add=True)               # When item was viewed
    liked               = models.BooleanField(help_text='If the item was liked this is set to true')</code></pre>
</div>
</div>
</p>

<p>My View is:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>class SeenViewSet(viewsets.ModelViewSet):
    queryset = Seen.objects.all().order_by('-date_seen')
    serializer_class = SeenSerializer

    def perform_create(self, serializer):
        the_user = User.objects.get(pk=self.request.data['who_saw'])
        serializer.save(who_saw=the_user)

        the_item = Item.objects.get(pk=self.request.data['item_seen'])
        serializer.save(item_seen=the_item)</code></pre>
</div>
</div>
</p>

<p>And my serializer is:</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>class SeenSerializer(serializers.HyperlinkedModelSerializer):
    username = serializers.SerializerMethodField()

    def get_username(self, obj):
        value = str(obj.who_saw)
        return value

    def get_keywords(self, obj):
        value = str(obj.keywords)
        return value

    class Meta:
        model = Seen
        fields = ('who_saw', 'item_seen', 'liked', 'date_seen', 'username')</code></pre>
</div>
</div>
</p>