Closed ChaisSt closed 3 years ago
You should post what the error is, no matter how vague it might be. It's better than nothing. Outside of that, looks fine to me.
Have you considered using something like BungieSharper to handle the client implementation for you?
I have not but honestly at this point I'm almost done with the project, I just need to get the transfer working on it and it'll be finished. Here's the error: {StatusCode: 500, ReasonPhrase: 'InternalServerError', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Access-Control-Allow-Origin: https://www.bungie.net Cache-Control: max-age=0, private CF-Cache-Status: DYNAMIC CF-RAY: 6411059fc957c7d1-DEN cf-request-id: 097e81d7dd0000c7d1f1272000000001 Connection: keep-alive Date: Fri, 16 Apr 2021 22:59:04 GMT Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct" Server: cloudflare Vary: Origin X-Android-Received-Millis: 1618613945261 X-Android-Response-Source: NETWORK 500 X-Android-Selected-Protocol: http/1.1 X-Android-Sent-Millis: 1618613945166 X-BungieNext-MID2: 103 X-BungieNext-Renderer: Frog Blast the Ventcore X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-SelfUrl: https://www.bungie.net/Platform/Destiny2/Actions/Items/TransferItem/ X-UA-Compatible: IE=edge X-Ventcore-Status: 3 Content-Length: 166 Content-Type: application/json; charset=utf-8 Expires: -1 }}
Wait, I see your problem now. In your TransferModel
your itemId
should be the instance ID, and your itemReferenceHash
should be the item hash. It looks like you've got them swapped.
For the record, this works for me:
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("X-API-Key", apiKey);
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
var request = new DestinyItemTransferRequest
{
ItemReferenceHash = item.ItemHash,
StackSize = 1,
TransferToVault = false,
ItemId = item.ItemInstanceId,
CharacterId = hunterCharacterId,
MembershipType = memberType
};
var stringMsg = JsonSerializer.Serialize(request);
var result = await httpClient.PostAsync("https://www.bungie.net/Platform/Destiny2/Actions/Items/TransferItem/", new StringContent(stringMsg));
It worked! Thank you so much for pointing that out to me, I really appreciate you!
I've been having trouble with getting the TransferItem endpoint to work and I'm not sure what the issue exactly is. The error message I get back is very vague, just a pretty basic internal server error which doesn't point to what the exact issue is... I'm creating the mobile app in Xamarin(C#), below is some relevant code.
ApiClient contains all the required headers that I know of(including oauth). I've checked all the variables to make sure they're getting populated. I've also checked string json and it looks fine to me. I've removed encoding and application/json from var content and the issue still exists.... I'm just kind of lost on where I'm going wrong.