I am using a Asp.net web api to send data from an app to the API and insert into sql server.
This is DDL of my table, and my stored procedure that I am attempting to execute as well as the format of the data that is being sent. The issue is that I am attempting to assign a string value and I need to convert the string value to a binary(64) value before it hits the stored procedure. How do I do this?
--URL being sent to API
XXX.XXX.XX.XXX:XXX/api/user/adduser?firstparam="a"&secparam="b"&thirparam="c"&fourparam="d"&fiveparam="e"&sixparam=123
--SQL DDL
CREATE TABLE [dbo].[data1](
[ID] [int] IDENTITY(1,1) NOT NULL,
[badgeIn] [varchar](100) NOT NULL,
[supIn] [varchar](100) NOT NULL,
[phone] [varchar](10) NULL,
[lsc] [varchar](100) NOT NULL,
[email] [varchar](100) NOT NULL,
[gona] [binary](64) NOT NULL
PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET IDENTITY_INSERT [dbo].[data1] ON
GO
INSERT [dbo].[data1] ([ID], [badgeIn], [supIn], [phone], [lsc], [email], [gona]) VALUES (1, N'R183', N'TX1384', N'5555555555', N'Test', N'test1234@test.com', 0x477265656E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
GO
SET IDENTITY_INSERT [dbo].[data1] OFF
GO
--Stored Proc
ALTER PROCEDURE [dbo].[InsertData] @badgeIn varchar(100), @supIn varchar(100), @Phone varchar(100), @lsc varchar(100), @Email varchar(100), @gona binary(64)
AS
INSERT INTO dbo.appinfo (badgeIn, supIn, phone, lsc, email, gona) VALUES (@badgeIn, @supIn, @Phone, @lsc, @Email, @gona)\
EDIT
The error shown in my response
variable is:
{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.NSUrlSessionHandler+NSUrlSessionDataTaskStreamContent, Headers: { Pragma: no-cache X-Powered-By: ASP.NET Server: Microsoft-IIS/10.0 X-AspNet-Version: 4.0.30319 Date: Fri, 23 Nov 2018 13:32:43 GMT Cache-Control: no-cache Content-Type: application/json; charset=utf-8 X-Powered-By: ASP.NET X-AspNet-Version: 4.0.30319 Content-Length: 36 Expires: -1 }}
And this is how I send data to API
var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(url, jsonData);
var result = await response.Content.ReadAsStringAsync();